From 5a22df59f962368ab4668fc254191bd7c6144e4c Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Thu, 20 Apr 2017 19:00:21 -0700 Subject: [PATCH] Create proper include directory for CoreFoundation --- CFArray.h | 697 +--------- CFAttributedString.h | 41 +- CFAvailability.h | 234 +--- CFBag.h | 116 +- CFBase.h | 619 +-------- CFBasicHash.h | 157 +-- CFBigNumber.h | 94 +- CFBinaryHeap.h | 313 +---- CFBitVector.h | 68 +- CFBundle.h | 359 +---- CFBundlePriv.h | 305 +---- CFBundle_BinaryTypes.h | 73 +- CFBundle_Internal.h | 375 +----- CFBurstTrie.h | 200 +-- CFByteOrder.h | 324 +---- CFCalendar.h | 136 +- CFCharacterSet.h | 406 +----- CFCharacterSetPriv.h | 92 +- CFData.h | 98 +- CFDate.h | 132 +- CFDateFormatter.h | 175 +-- CFDictionary.h | 693 +--------- CFError.h | 198 +-- CFError_Private.h | 53 +- CFFileDescriptor.h | 40 +- CFFileSecurity.h | 48 +- CFICUConverters.h | 49 +- CFICULogging.h | 119 +- CFInternal.h | 806 +----------- CFLocale.h | 217 +-- CFLocaleInternal.h | 146 +-- CFLogUtilities.h | 65 +- CFMachPort.h | 69 +- CFMessagePort.h | 88 +- CFNotificationCenter.h | 38 +- CFNumber.h | 148 +-- CFNumberFormatter.h | 187 +-- CFPlugIn.h | 143 +- CFPlugInCOM.h | 119 +- CFPlugIn_Factory.h | 64 +- CFPreferences.h | 147 +-- CFPriv.h | 661 +--------- CFPropertyList.h | 177 +-- CFRunLoop.h | 207 +-- CFRuntime.h | 282 +--- CFSet.h | 510 +------- CFSocket.h | 239 +--- CFStorage.h | 315 +---- CFStream.h | 309 +---- CFStreamAbstract.h | 213 +-- CFStreamInternal.h | 75 +- CFStreamPriv.h | 199 +-- CFString.h | 892 +------------ CFStringDefaultEncoding.h | 64 +- CFStringEncodingConverter.h | 112 +- CFStringEncodingConverterExt.h | 131 +- CFStringEncodingConverterPriv.h | 50 +- CFStringEncodingDatabase.h | 44 +- CFStringEncodingExt.h | 203 +-- CFStringTokenizer.h | 47 +- CFTimeZone.h | 115 +- CFTree.h | 350 +---- CFURL.h | 1161 +---------------- CFURL.inc.h | 365 +----- CFURLAccess.h | 147 +-- CFURLEnumerator.h | 43 +- CFURLPriv.h | 693 +--------- CFUUID.h | 97 +- CFUniChar.h | 271 +--- CFUniCharPriv.h | 49 +- CFUnicodeDecomposition.h | 57 +- CFUnicodePrecomposition.h | 49 +- CFUserNotification.h | 206 +-- CFUtilities.h | 46 +- CFXMLInputStream.h | 110 +- CFXMLNode.h | 211 +-- CFXMLParser.h | 295 +---- CFXPCBridge.h | 38 +- CoreFoundation | 1 - CoreFoundation.h | 117 +- ForFoundationOnly.h | 640 +-------- FoundationExceptions.h | 40 +- GNUstep.h | 80 +- GSInvocation.h | 91 +- GSObjCRuntime.h | 630 +-------- NSBasicHash.h | 97 +- NSBlock.h | 86 +- NSGenericDeallocHandler.h | 17 +- NSInvocationInternal.h | 11 +- NSMessageBuilder.h | 20 +- NSNumberInternal.h | 92 +- NSObjCRuntimeInternal.h | 25 +- NSSharedKeyDictionary.h | 31 +- NSSharedKeySet.h | 30 +- NSZombie.h | 15 +- TargetConditionals.h | 18 +- _CFUtilities.h | 11 +- include/CoreFoundation/CFArray.h | 696 ++++++++++ include/CoreFoundation/CFAttributedString.h | 40 + include/CoreFoundation/CFAvailability.h | 233 ++++ include/CoreFoundation/CFBag.h | 115 ++ include/CoreFoundation/CFBase.h | 618 +++++++++ include/CoreFoundation/CFBasicHash.h | 156 +++ include/CoreFoundation/CFBigNumber.h | 93 ++ include/CoreFoundation/CFBinaryHeap.h | 312 +++++ include/CoreFoundation/CFBitVector.h | 67 + include/CoreFoundation/CFBundle.h | 358 +++++ include/CoreFoundation/CFBundlePriv.h | 304 +++++ include/CoreFoundation/CFBundle_BinaryTypes.h | 72 + include/CoreFoundation/CFBundle_Internal.h | 374 ++++++ include/CoreFoundation/CFBurstTrie.h | 199 +++ include/CoreFoundation/CFByteOrder.h | 323 +++++ include/CoreFoundation/CFCalendar.h | 135 ++ include/CoreFoundation/CFCharacterSet.h | 405 ++++++ include/CoreFoundation/CFCharacterSetPriv.h | 91 ++ include/CoreFoundation/CFData.h | 97 ++ include/CoreFoundation/CFDate.h | 131 ++ include/CoreFoundation/CFDateFormatter.h | 174 +++ include/CoreFoundation/CFDictionary.h | 692 ++++++++++ include/CoreFoundation/CFError.h | 197 +++ include/CoreFoundation/CFError_Private.h | 52 + include/CoreFoundation/CFFileDescriptor.h | 39 + include/CoreFoundation/CFFileSecurity.h | 47 + include/CoreFoundation/CFICUConverters.h | 48 + include/CoreFoundation/CFICULogging.h | 118 ++ include/CoreFoundation/CFInternal.h | 805 ++++++++++++ include/CoreFoundation/CFLocale.h | 216 +++ include/CoreFoundation/CFLocaleInternal.h | 145 ++ include/CoreFoundation/CFLogUtilities.h | 64 + include/CoreFoundation/CFMachPort.h | 68 + include/CoreFoundation/CFMessagePort.h | 87 ++ include/CoreFoundation/CFNotificationCenter.h | 37 + include/CoreFoundation/CFNumber.h | 147 +++ include/CoreFoundation/CFNumberFormatter.h | 186 +++ include/CoreFoundation/CFPlugIn.h | 142 ++ include/CoreFoundation/CFPlugInCOM.h | 118 ++ include/CoreFoundation/CFPlugIn_Factory.h | 63 + include/CoreFoundation/CFPreferences.h | 146 +++ include/CoreFoundation/CFPriv.h | 660 ++++++++++ include/CoreFoundation/CFPropertyList.h | 176 +++ include/CoreFoundation/CFRunLoop.h | 206 +++ include/CoreFoundation/CFRuntime.h | 281 ++++ include/CoreFoundation/CFSet.h | 509 ++++++++ include/CoreFoundation/CFSocket.h | 238 ++++ include/CoreFoundation/CFStorage.h | 314 +++++ include/CoreFoundation/CFStream.h | 308 +++++ include/CoreFoundation/CFStreamAbstract.h | 212 +++ include/CoreFoundation/CFStreamInternal.h | 74 ++ include/CoreFoundation/CFStreamPriv.h | 198 +++ include/CoreFoundation/CFString.h | 891 +++++++++++++ .../CoreFoundation/CFStringDefaultEncoding.h | 63 + .../CFStringEncodingConverter.h | 111 ++ .../CFStringEncodingConverterExt.h | 130 ++ .../CFStringEncodingConverterPriv.h | 49 + .../CoreFoundation/CFStringEncodingDatabase.h | 43 + include/CoreFoundation/CFStringEncodingExt.h | 202 +++ include/CoreFoundation/CFStringTokenizer.h | 46 + include/CoreFoundation/CFTimeZone.h | 114 ++ include/CoreFoundation/CFTree.h | 349 +++++ include/CoreFoundation/CFURL.h | 1160 ++++++++++++++++ include/CoreFoundation/CFURL.inc.h | 364 ++++++ include/CoreFoundation/CFURLAccess.h | 146 +++ include/CoreFoundation/CFURLEnumerator.h | 42 + include/CoreFoundation/CFURLPriv.h | 692 ++++++++++ include/CoreFoundation/CFUUID.h | 96 ++ include/CoreFoundation/CFUniChar.h | 270 ++++ include/CoreFoundation/CFUniCharPriv.h | 48 + .../CoreFoundation/CFUnicodeDecomposition.h | 56 + .../CoreFoundation/CFUnicodePrecomposition.h | 48 + include/CoreFoundation/CFUserNotification.h | 205 +++ include/CoreFoundation/CFUtilities.h | 45 + include/CoreFoundation/CFXMLInputStream.h | 109 ++ include/CoreFoundation/CFXMLNode.h | 210 +++ include/CoreFoundation/CFXMLParser.h | 294 +++++ include/CoreFoundation/CFXPCBridge.h | 37 + include/CoreFoundation/CoreFoundation.h | 116 ++ include/CoreFoundation/ForFoundationOnly.h | 639 +++++++++ include/CoreFoundation/FoundationExceptions.h | 39 + include/CoreFoundation/GNUstep.h | 79 ++ include/CoreFoundation/GSInvocation.h | 90 ++ include/CoreFoundation/GSObjCRuntime.h | 629 +++++++++ include/CoreFoundation/NSBasicHash.h | 96 ++ include/CoreFoundation/NSBlock.h | 85 ++ .../CoreFoundation/NSGenericDeallocHandler.h | 16 + include/CoreFoundation/NSInvocationInternal.h | 10 + include/CoreFoundation/NSMessageBuilder.h | 19 + include/CoreFoundation/NSNumberInternal.h | 91 ++ .../CoreFoundation/NSObjCRuntimeInternal.h | 24 + .../CoreFoundation/NSSharedKeyDictionary.h | 30 + include/CoreFoundation/NSSharedKeySet.h | 29 + include/CoreFoundation/NSZombie.h | 14 + include/CoreFoundation/TargetConditionals.h | 17 + include/CoreFoundation/_CFUtilities.h | 10 + 193 files changed, 19535 insertions(+), 19440 deletions(-) mode change 100644 => 120000 CFArray.h mode change 100644 => 120000 CFAttributedString.h mode change 100644 => 120000 CFAvailability.h mode change 100644 => 120000 CFBag.h mode change 100644 => 120000 CFBase.h mode change 100644 => 120000 CFBasicHash.h mode change 100644 => 120000 CFBigNumber.h mode change 100644 => 120000 CFBinaryHeap.h mode change 100644 => 120000 CFBitVector.h mode change 100644 => 120000 CFBundle.h mode change 100644 => 120000 CFBundlePriv.h mode change 100644 => 120000 CFBundle_BinaryTypes.h mode change 100644 => 120000 CFBundle_Internal.h mode change 100644 => 120000 CFBurstTrie.h mode change 100644 => 120000 CFByteOrder.h mode change 100644 => 120000 CFCalendar.h mode change 100644 => 120000 CFCharacterSet.h mode change 100644 => 120000 CFCharacterSetPriv.h mode change 100644 => 120000 CFData.h mode change 100644 => 120000 CFDate.h mode change 100644 => 120000 CFDateFormatter.h mode change 100644 => 120000 CFDictionary.h mode change 100644 => 120000 CFError.h mode change 100644 => 120000 CFError_Private.h mode change 100644 => 120000 CFFileDescriptor.h mode change 100644 => 120000 CFFileSecurity.h mode change 100644 => 120000 CFICUConverters.h mode change 100644 => 120000 CFICULogging.h mode change 100644 => 120000 CFInternal.h mode change 100644 => 120000 CFLocale.h mode change 100644 => 120000 CFLocaleInternal.h mode change 100644 => 120000 CFLogUtilities.h mode change 100644 => 120000 CFMachPort.h mode change 100644 => 120000 CFMessagePort.h mode change 100644 => 120000 CFNotificationCenter.h mode change 100644 => 120000 CFNumber.h mode change 100644 => 120000 CFNumberFormatter.h mode change 100644 => 120000 CFPlugIn.h mode change 100644 => 120000 CFPlugInCOM.h mode change 100644 => 120000 CFPlugIn_Factory.h mode change 100644 => 120000 CFPreferences.h mode change 100644 => 120000 CFPriv.h mode change 100644 => 120000 CFPropertyList.h mode change 100644 => 120000 CFRunLoop.h mode change 100644 => 120000 CFRuntime.h mode change 100644 => 120000 CFSet.h mode change 100644 => 120000 CFSocket.h mode change 100644 => 120000 CFStorage.h mode change 100644 => 120000 CFStream.h mode change 100644 => 120000 CFStreamAbstract.h mode change 100644 => 120000 CFStreamInternal.h mode change 100644 => 120000 CFStreamPriv.h mode change 100644 => 120000 CFString.h mode change 100644 => 120000 CFStringDefaultEncoding.h mode change 100644 => 120000 CFStringEncodingConverter.h mode change 100644 => 120000 CFStringEncodingConverterExt.h mode change 100644 => 120000 CFStringEncodingConverterPriv.h mode change 100644 => 120000 CFStringEncodingDatabase.h mode change 100644 => 120000 CFStringEncodingExt.h mode change 100644 => 120000 CFStringTokenizer.h mode change 100644 => 120000 CFTimeZone.h mode change 100644 => 120000 CFTree.h mode change 100644 => 120000 CFURL.h mode change 100644 => 120000 CFURL.inc.h mode change 100644 => 120000 CFURLAccess.h mode change 100644 => 120000 CFURLEnumerator.h mode change 100644 => 120000 CFURLPriv.h mode change 100644 => 120000 CFUUID.h mode change 100644 => 120000 CFUniChar.h mode change 100644 => 120000 CFUniCharPriv.h mode change 100644 => 120000 CFUnicodeDecomposition.h mode change 100644 => 120000 CFUnicodePrecomposition.h mode change 100644 => 120000 CFUserNotification.h mode change 100644 => 120000 CFUtilities.h mode change 100644 => 120000 CFXMLInputStream.h mode change 100644 => 120000 CFXMLNode.h mode change 100644 => 120000 CFXMLParser.h mode change 100644 => 120000 CFXPCBridge.h delete mode 120000 CoreFoundation mode change 100644 => 120000 CoreFoundation.h mode change 100644 => 120000 ForFoundationOnly.h mode change 100644 => 120000 FoundationExceptions.h mode change 100644 => 120000 GNUstep.h mode change 100644 => 120000 GSInvocation.h mode change 100644 => 120000 GSObjCRuntime.h mode change 100644 => 120000 NSBasicHash.h mode change 100644 => 120000 NSBlock.h mode change 100644 => 120000 NSGenericDeallocHandler.h mode change 100644 => 120000 NSInvocationInternal.h mode change 100644 => 120000 NSMessageBuilder.h mode change 100644 => 120000 NSNumberInternal.h mode change 100644 => 120000 NSObjCRuntimeInternal.h mode change 100644 => 120000 NSSharedKeyDictionary.h mode change 100644 => 120000 NSSharedKeySet.h mode change 100644 => 120000 NSZombie.h mode change 100644 => 120000 TargetConditionals.h mode change 100644 => 120000 _CFUtilities.h create mode 100644 include/CoreFoundation/CFArray.h create mode 100644 include/CoreFoundation/CFAttributedString.h create mode 100644 include/CoreFoundation/CFAvailability.h create mode 100644 include/CoreFoundation/CFBag.h create mode 100644 include/CoreFoundation/CFBase.h create mode 100644 include/CoreFoundation/CFBasicHash.h create mode 100644 include/CoreFoundation/CFBigNumber.h create mode 100644 include/CoreFoundation/CFBinaryHeap.h create mode 100644 include/CoreFoundation/CFBitVector.h create mode 100644 include/CoreFoundation/CFBundle.h create mode 100644 include/CoreFoundation/CFBundlePriv.h create mode 100644 include/CoreFoundation/CFBundle_BinaryTypes.h create mode 100644 include/CoreFoundation/CFBundle_Internal.h create mode 100644 include/CoreFoundation/CFBurstTrie.h create mode 100644 include/CoreFoundation/CFByteOrder.h create mode 100644 include/CoreFoundation/CFCalendar.h create mode 100644 include/CoreFoundation/CFCharacterSet.h create mode 100644 include/CoreFoundation/CFCharacterSetPriv.h create mode 100644 include/CoreFoundation/CFData.h create mode 100644 include/CoreFoundation/CFDate.h create mode 100644 include/CoreFoundation/CFDateFormatter.h create mode 100644 include/CoreFoundation/CFDictionary.h create mode 100644 include/CoreFoundation/CFError.h create mode 100644 include/CoreFoundation/CFError_Private.h create mode 100644 include/CoreFoundation/CFFileDescriptor.h create mode 100644 include/CoreFoundation/CFFileSecurity.h create mode 100644 include/CoreFoundation/CFICUConverters.h create mode 100644 include/CoreFoundation/CFICULogging.h create mode 100644 include/CoreFoundation/CFInternal.h create mode 100644 include/CoreFoundation/CFLocale.h create mode 100644 include/CoreFoundation/CFLocaleInternal.h create mode 100644 include/CoreFoundation/CFLogUtilities.h create mode 100644 include/CoreFoundation/CFMachPort.h create mode 100644 include/CoreFoundation/CFMessagePort.h create mode 100644 include/CoreFoundation/CFNotificationCenter.h create mode 100644 include/CoreFoundation/CFNumber.h create mode 100644 include/CoreFoundation/CFNumberFormatter.h create mode 100644 include/CoreFoundation/CFPlugIn.h create mode 100644 include/CoreFoundation/CFPlugInCOM.h create mode 100644 include/CoreFoundation/CFPlugIn_Factory.h create mode 100644 include/CoreFoundation/CFPreferences.h create mode 100644 include/CoreFoundation/CFPriv.h create mode 100644 include/CoreFoundation/CFPropertyList.h create mode 100644 include/CoreFoundation/CFRunLoop.h create mode 100644 include/CoreFoundation/CFRuntime.h create mode 100644 include/CoreFoundation/CFSet.h create mode 100644 include/CoreFoundation/CFSocket.h create mode 100644 include/CoreFoundation/CFStorage.h create mode 100644 include/CoreFoundation/CFStream.h create mode 100644 include/CoreFoundation/CFStreamAbstract.h create mode 100644 include/CoreFoundation/CFStreamInternal.h create mode 100644 include/CoreFoundation/CFStreamPriv.h create mode 100644 include/CoreFoundation/CFString.h create mode 100644 include/CoreFoundation/CFStringDefaultEncoding.h create mode 100644 include/CoreFoundation/CFStringEncodingConverter.h create mode 100644 include/CoreFoundation/CFStringEncodingConverterExt.h create mode 100644 include/CoreFoundation/CFStringEncodingConverterPriv.h create mode 100644 include/CoreFoundation/CFStringEncodingDatabase.h create mode 100644 include/CoreFoundation/CFStringEncodingExt.h create mode 100644 include/CoreFoundation/CFStringTokenizer.h create mode 100644 include/CoreFoundation/CFTimeZone.h create mode 100644 include/CoreFoundation/CFTree.h create mode 100644 include/CoreFoundation/CFURL.h create mode 100644 include/CoreFoundation/CFURL.inc.h create mode 100644 include/CoreFoundation/CFURLAccess.h create mode 100644 include/CoreFoundation/CFURLEnumerator.h create mode 100644 include/CoreFoundation/CFURLPriv.h create mode 100644 include/CoreFoundation/CFUUID.h create mode 100644 include/CoreFoundation/CFUniChar.h create mode 100644 include/CoreFoundation/CFUniCharPriv.h create mode 100644 include/CoreFoundation/CFUnicodeDecomposition.h create mode 100644 include/CoreFoundation/CFUnicodePrecomposition.h create mode 100644 include/CoreFoundation/CFUserNotification.h create mode 100644 include/CoreFoundation/CFUtilities.h create mode 100644 include/CoreFoundation/CFXMLInputStream.h create mode 100644 include/CoreFoundation/CFXMLNode.h create mode 100644 include/CoreFoundation/CFXMLParser.h create mode 100644 include/CoreFoundation/CFXPCBridge.h create mode 100644 include/CoreFoundation/CoreFoundation.h create mode 100644 include/CoreFoundation/ForFoundationOnly.h create mode 100644 include/CoreFoundation/FoundationExceptions.h create mode 100644 include/CoreFoundation/GNUstep.h create mode 100644 include/CoreFoundation/GSInvocation.h create mode 100644 include/CoreFoundation/GSObjCRuntime.h create mode 100644 include/CoreFoundation/NSBasicHash.h create mode 100644 include/CoreFoundation/NSBlock.h create mode 100644 include/CoreFoundation/NSGenericDeallocHandler.h create mode 100644 include/CoreFoundation/NSInvocationInternal.h create mode 100644 include/CoreFoundation/NSMessageBuilder.h create mode 100644 include/CoreFoundation/NSNumberInternal.h create mode 100644 include/CoreFoundation/NSObjCRuntimeInternal.h create mode 100644 include/CoreFoundation/NSSharedKeyDictionary.h create mode 100644 include/CoreFoundation/NSSharedKeySet.h create mode 100644 include/CoreFoundation/NSZombie.h create mode 100644 include/CoreFoundation/TargetConditionals.h create mode 100644 include/CoreFoundation/_CFUtilities.h diff --git a/CFArray.h b/CFArray.h deleted file mode 100644 index 96d98fe..0000000 --- a/CFArray.h +++ /dev/null @@ -1,696 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFArray.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -/*! - @header CFArray - CFArray implements an ordered, compact container of pointer-sized - values. Values are accessed via integer keys (indices), from the - range 0 to N-1, where N is the number of values in the array when - an operation is performed. The array is said to be "compact" because - deleted or inserted values do not leave a gap in the key space -- - the values with higher-numbered indices have their indices - renumbered lower (or higher, in the case of insertion) so that the - set of valid indices is always in the integer range [0, N-1]. Thus, - the index to access a particular value in the array may change over - time as other values are inserted into or deleted from the array. - - Arrays come in two flavors, immutable, which cannot have values - added to them or removed from them after the array is created, and - mutable, to which you can add values or from which remove values. - Mutable arrays can have an unlimited number of values (or rather, - limited only by constraints external to CFArray, like the amount - of available memory). - - As with all CoreFoundation collection types, arrays maintain hard - references on the values you put in them, but the retaining and - releasing functions are user-defined callbacks that can actually do - whatever the user wants (for example, nothing). - - Computational Complexity - The access time for a value in the array is guaranteed to be at - worst O(lg N) for any implementation, current and future, but will - often be O(1) (constant time). Linear search operations similarly - have a worst case complexity of O(N*lg N), though typically the - bounds will be tighter, and so on. Insertion or deletion operations - will typically be linear in the number of values in the array, but - may be O(N*lg N) clearly in the worst case in some implementations. - There are no favored positions within the array for performance; - that is, it is not necessarily faster to access values with low - indices, or to insert or delete values with high indices, or - whatever. -*/ - -#if !defined(__COREFOUNDATION_CFARRAY__) -#define __COREFOUNDATION_CFARRAY__ 1 - -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -/*! - @typedef CFArrayCallBacks - Structure containing the callbacks of a CFArray. - @field version The version number of the structure type being passed - in as a parameter to the CFArray creation functions. This - structure is version 0. - @field retain The callback used to add a retain for the array on - values as they are put into the array. This callback returns - the value to store in the array, which is usually the value - parameter passed to this callback, but may be a different - value if a different value should be stored in the array. - The array's allocator is passed as the first argument. - @field release The callback used to remove a retain previously added - for the array from values as they are removed from the - array. The array's allocator is passed as the first - argument. - @field copyDescription The callback used to create a descriptive - string representation of each value in the array. This is - used by the CFCopyDescription() function. - @field equal The callback used to compare values in the array for - equality for some operations. -*/ -typedef const void * (*CFArrayRetainCallBack)(CFAllocatorRef allocator, const void *value); -typedef void (*CFArrayReleaseCallBack)(CFAllocatorRef allocator, const void *value); -typedef CFStringRef (*CFArrayCopyDescriptionCallBack)(const void *value); -typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2); -typedef struct { - CFIndex version; - CFArrayRetainCallBack retain; - CFArrayReleaseCallBack release; - CFArrayCopyDescriptionCallBack copyDescription; - CFArrayEqualCallBack equal; -} CFArrayCallBacks; - -/*! - @constant kCFTypeArrayCallBacks - Predefined CFArrayCallBacks structure containing a set of callbacks - appropriate for use when the values in a CFArray are all CFTypes. -*/ -CF_EXPORT -const CFArrayCallBacks kCFTypeArrayCallBacks; - -/*! - @typedef CFArrayApplierFunction - Type of the callback function used by the apply functions of - CFArrays. - @param value The current value from the array. - @param context The user-defined context parameter given to the apply - function. -*/ -typedef void (*CFArrayApplierFunction)(const void *value, void *context); - -/*! - @typedef CFArrayRef - This is the type of a reference to immutable CFArrays. -*/ -typedef const struct CF_BRIDGED_TYPE(NSArray) __CFArray * CFArrayRef; - -/*! - @typedef CFMutableArrayRef - This is the type of a reference to mutable CFArrays. -*/ -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableArray) __CFArray * CFMutableArrayRef; - -/*! - @function CFArrayGetTypeID - Returns the type identifier of all CFArray instances. -*/ -CF_EXPORT -CFTypeID CFArrayGetTypeID(void); - -/*! - @function CFArrayCreate - Creates a new immutable array with the given values. - @param allocator The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param values A C array of the pointer-sized values to be in the - array. The values in the array are ordered in the same order - in which they appear in this C array. This parameter may be - NULL if the numValues parameter is 0. This C array is not - changed or freed by this function. If this parameter is not - a valid pointer to a C array of at least numValues pointers, - the behavior is undefined. - @param numValues The number of values to copy from the values C - array into the CFArray. This number will be the count of the - array. - If this parameter is negative, or greater than the number of - values actually in the value's C array, the behavior is - undefined. - @param callBacks A pointer to a CFArrayCallBacks structure - initialized with the callbacks for the array to use on each - value in the array. The retain callback will be used within - this function, for example, to retain all of the new values - from the values C array. A copy of the contents of the - callbacks structure is made, so that a pointer to a - structure on the stack can be passed in, or can be reused - for multiple array creations. If the version field of this - callbacks structure is not one of the defined ones for - CFArray, the behavior is undefined. The retain field may be - NULL, in which case the CFArray will do nothing to add a - retain to the contained values for the array. The release - field may be NULL, in which case the CFArray will do nothing - to remove the array's retain (if any) on the values when the - array is destroyed. If the copyDescription field is NULL, - the array will create a simple description for the value. If - the equal field is NULL, the array will use pointer equality - to test for equality of values. This callbacks parameter - itself may be NULL, which is treated as if a valid structure - of version 0 with all fields NULL had been passed in. - Otherwise, if any of the fields are not valid pointers to - functions of the correct type, or this parameter is not a - valid pointer to a CFArrayCallBacks callbacks structure, - the behavior is undefined. If any of the values put into the - array is not one understood by one of the callback functions - the behavior when that callback function is used is - undefined. - @result A reference to the new immutable CFArray. -*/ -CF_EXPORT -CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks); - -/*! - @function CFArrayCreateCopy - Creates a new immutable array with the values from the given array. - @param allocator The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param theArray The array which is to be copied. The values from the - array are copied as pointers into the new array (that is, - the values themselves are copied, not that which the values - point to, if anything). However, the values are also - retained by the new array. The count of the new array will - be the same as the given array. The new array uses the same - callbacks as the array to be copied. If this parameter is - not a valid CFArray, the behavior is undefined. - @result A reference to the new immutable CFArray. -*/ -CF_EXPORT -CFArrayRef CFArrayCreateCopy(CFAllocatorRef allocator, CFArrayRef theArray); - -/*! - @function CFArrayCreateMutable - Creates a new empty mutable array. - @param allocator The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param capacity A hint about the number of values that will be held - by the CFArray. Pass 0 for no hint. The implementation may - ignore this hint, or may use it to optimize various - operations. An array's actual capacity is only limited by - address space and available memory constraints). If this - parameter is negative, the behavior is undefined. - @param callBacks A pointer to a CFArrayCallBacks structure - initialized with the callbacks for the array to use on each - value in the array. A copy of the contents of the - callbacks structure is made, so that a pointer to a - structure on the stack can be passed in, or can be reused - for multiple array creations. If the version field of this - callbacks structure is not one of the defined ones for - CFArray, the behavior is undefined. The retain field may be - NULL, in which case the CFArray will do nothing to add a - retain to the contained values for the array. The release - field may be NULL, in which case the CFArray will do nothing - to remove the array's retain (if any) on the values when the - array is destroyed. If the copyDescription field is NULL, - the array will create a simple description for the value. If - the equal field is NULL, the array will use pointer equality - to test for equality of values. This callbacks parameter - itself may be NULL, which is treated as if a valid structure - of version 0 with all fields NULL had been passed in. - Otherwise, if any of the fields are not valid pointers to - functions of the correct type, or this parameter is not a - valid pointer to a CFArrayCallBacks callbacks structure, - the behavior is undefined. If any of the values put into the - array is not one understood by one of the callback functions - the behavior when that callback function is used is - undefined. - @result A reference to the new mutable CFArray. -*/ -CF_EXPORT -CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks); - -/*! - @function CFArrayCreateMutableCopy - Creates a new mutable array with the values from the given array. - @param allocator The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param capacity A hint about the number of values that will be held - by the CFArray. Pass 0 for no hint. The implementation may - ignore this hint, or may use it to optimize various - operations. An array's actual capacity is only limited by - address space and available memory constraints). - This parameter must be greater than or equal - to the count of the array which is to be copied, or the - behavior is undefined. If this parameter is negative, the - behavior is undefined. - @param theArray The array which is to be copied. The values from the - array are copied as pointers into the new array (that is, - the values themselves are copied, not that which the values - point to, if anything). However, the values are also - retained by the new array. The count of the new array will - be the same as the given array. The new array uses the same - callbacks as the array to be copied. If this parameter is - not a valid CFArray, the behavior is undefined. - @result A reference to the new mutable CFArray. -*/ -CF_EXPORT -CFMutableArrayRef CFArrayCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFArrayRef theArray); - -/*! - @function CFArrayGetCount - Returns the number of values currently in the array. - @param theArray The array to be queried. If this parameter is not a valid - CFArray, the behavior is undefined. - @result The number of values in the array. -*/ -CF_EXPORT -CFIndex CFArrayGetCount(CFArrayRef theArray); - -/*! - @function CFArrayGetCountOfValue - Counts the number of times the given value occurs in the array. - @param theArray The array to be searched. If this parameter is not a - valid CFArray, the behavior is undefined. - @param range The range within the array to search. If the range - location or end point (defined by the location plus length - minus 1) is outside the index space of the array (0 to - N-1 inclusive, where N is the count of the array), the - behavior is undefined. If the range length is negative, the - behavior is undefined. The range may be empty (length 0). - @param value The value for which to find matches in the array. The - equal() callback provided when the array was created is - used to compare. If the equal() callback was NULL, pointer - equality (in C, ==) is used. If value, or any of the values - in the array, are not understood by the equal() callback, - the behavior is undefined. - @result The number of times the given value occurs in the array, - within the specified range. -*/ -CF_EXPORT -CFIndex CFArrayGetCountOfValue(CFArrayRef theArray, CFRange range, const void *value); - -/*! - @function CFArrayContainsValue - Reports whether or not the value is in the array. - @param theArray The array to be searched. If this parameter is not a - valid CFArray, the behavior is undefined. - @param range The range within the array to search. If the range - location or end point (defined by the location plus length - minus 1) is outside the index space of the array (0 to - N-1 inclusive, where N is the count of the array), the - behavior is undefined. If the range length is negative, the - behavior is undefined. The range may be empty (length 0). - @param value The value for which to find matches in the array. The - equal() callback provided when the array was created is - used to compare. If the equal() callback was NULL, pointer - equality (in C, ==) is used. If value, or any of the values - in the array, are not understood by the equal() callback, - the behavior is undefined. - @result true, if the value is in the specified range of the array, - otherwise false. -*/ -CF_EXPORT -Boolean CFArrayContainsValue(CFArrayRef theArray, CFRange range, const void *value); - -/*! - @function CFArrayGetValueAtIndex - Retrieves the value at the given index. - @param theArray The array to be queried. If this parameter is not a - valid CFArray, the behavior is undefined. - @param idx The index of the value to retrieve. If the index is - outside the index space of the array (0 to N-1 inclusive, - where N is the count of the array), the behavior is - undefined. - @result The value with the given index in the array. -*/ -CF_EXPORT -const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx); - -/*! - @function CFArrayGetValues - Fills the buffer with values from the array. - @param theArray The array to be queried. If this parameter is not a - valid CFArray, the behavior is undefined. - @param range The range of values within the array to retrieve. If - the range location or end point (defined by the location - plus length minus 1) is outside the index space of the - array (0 to N-1 inclusive, where N is the count of the - array), the behavior is undefined. If the range length is - negative, the behavior is undefined. The range may be empty - (length 0), in which case no values are put into the buffer. - @param values A C array of pointer-sized values to be filled with - values from the array. The values in the C array are ordered - in the same order in which they appear in the array. If this - parameter is not a valid pointer to a C array of at least - range.length pointers, the behavior is undefined. -*/ -CF_EXPORT -void CFArrayGetValues(CFArrayRef theArray, CFRange range, const void **values); - -/*! - @function CFArrayApplyFunction - Calls a function once for each value in the array. - @param theArray The array to be operated upon. If this parameter is not - a valid CFArray, the behavior is undefined. - @param range The range of values within the array to which to apply - the function. If the range location or end point (defined by - the location plus length minus 1) is outside the index - space of the array (0 to N-1 inclusive, where N is the count - of the array), the behavior is undefined. If the range - length is negative, the behavior is undefined. The range may - be empty (length 0). - @param applier The callback function to call once for each value in - the given range in the array. If this parameter is not a - pointer to a function of the correct prototype, the behavior - is undefined. If there are values in the range which the - applier function does not expect or cannot properly apply - to, the behavior is undefined. - @param context A pointer-sized user-defined value, which is passed - as the second parameter to the applier function, but is - otherwise unused by this function. If the context is not - what is expected by the applier function, the behavior is - undefined. -*/ -CF_EXPORT -void CFArrayApplyFunction(CFArrayRef theArray, CFRange range, CFArrayApplierFunction applier, void *context); - -/*! - @function CFArrayGetFirstIndexOfValue - Searches the array for the value. - @param theArray The array to be searched. If this parameter is not a - valid CFArray, the behavior is undefined. - @param range The range within the array to search. If the range - location or end point (defined by the location plus length - minus 1) is outside the index space of the array (0 to - N-1 inclusive, where N is the count of the array), the - behavior is undefined. If the range length is negative, the - behavior is undefined. The range may be empty (length 0). - The search progresses from the smallest index defined by - the range to the largest. - @param value The value for which to find a match in the array. The - equal() callback provided when the array was created is - used to compare. If the equal() callback was NULL, pointer - equality (in C, ==) is used. If value, or any of the values - in the array, are not understood by the equal() callback, - the behavior is undefined. - @result The lowest index of the matching values in the range, or - kCFNotFound if no value in the range matched. -*/ -CF_EXPORT -CFIndex CFArrayGetFirstIndexOfValue(CFArrayRef theArray, CFRange range, const void *value); - -/*! - @function CFArrayGetLastIndexOfValue - Searches the array for the value. - @param theArray The array to be searched. If this parameter is not a - valid CFArray, the behavior is undefined. - @param range The range within the array to search. If the range - location or end point (defined by the location plus length - minus 1) is outside the index space of the array (0 to - N-1 inclusive, where N is the count of the array), the - behavior is undefined. If the range length is negative, the - behavior is undefined. The range may be empty (length 0). - The search progresses from the largest index defined by the - range to the smallest. - @param value The value for which to find a match in the array. The - equal() callback provided when the array was created is - used to compare. If the equal() callback was NULL, pointer - equality (in C, ==) is used. If value, or any of the values - in the array, are not understood by the equal() callback, - the behavior is undefined. - @result The highest index of the matching values in the range, or - kCFNotFound if no value in the range matched. -*/ -CF_EXPORT -CFIndex CFArrayGetLastIndexOfValue(CFArrayRef theArray, CFRange range, const void *value); - -/*! - @function CFArrayBSearchValues - Searches the array for the value using a binary search algorithm. - @param theArray The array to be searched. If this parameter is not a - valid CFArray, the behavior is undefined. If the array is - not sorted from least to greatest according to the - comparator function, the behavior is undefined. - @param range The range within the array to search. If the range - location or end point (defined by the location plus length - minus 1) is outside the index space of the array (0 to - N-1 inclusive, where N is the count of the array), the - behavior is undefined. If the range length is negative, the - behavior is undefined. The range may be empty (length 0). - @param value The value for which to find a match in the array. If - value, or any of the values in the array, are not understood - by the comparator callback, the behavior is undefined. - @param comparator The function with the comparator function type - signature which is used in the binary search operation to - compare values in the array with the given value. If this - parameter is not a pointer to a function of the correct - prototype, the behavior is undefined. If there are values - in the range which the comparator function does not expect - or cannot properly compare, the behavior is undefined. - @param context A pointer-sized user-defined value, which is passed - as the third parameter to the comparator function, but is - otherwise unused by this function. If the context is not - what is expected by the comparator function, the behavior is - undefined. - @result The return value is either 1) the index of a value that - matched, if the target value matches one or more in the - range, 2) greater than or equal to the end point of the - range, if the value is greater than all the values in the - range, or 3) the index of the value greater than the target - value, if the value lies between two of (or less than all - of) the values in the range. -*/ -CF_EXPORT -CFIndex CFArrayBSearchValues(CFArrayRef theArray, CFRange range, const void *value, CFComparatorFunction comparator, void *context); - -/*! - @function CFArrayAppendValue - Adds the value to the array giving it a new largest index. - @param theArray The array to which the value is to be added. If this - parameter is not a valid mutable CFArray, the behavior is - undefined. - @param value The value to add to the array. The value is retained by - the array using the retain callback provided when the array - was created. If the value is not of the sort expected by the - retain callback, the behavior is undefined. The value is - assigned to the index one larger than the previous largest - index, and the count of the array is increased by one. -*/ -CF_EXPORT -void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value); - -/*! - @function CFArrayInsertValueAtIndex - Adds the value to the array, giving it the given index. - @param theArray The array to which the value is to be added. If this - parameter is not a valid mutable CFArray, the behavior is - undefined. - @param idx The index to which to add the new value. If the index is - outside the index space of the array (0 to N inclusive, - where N is the count of the array before the operation), the - behavior is undefined. If the index is the same as N, this - function has the same effect as CFArrayAppendValue(). - @param value The value to add to the array. The value is retained by - the array using the retain callback provided when the array - was created. If the value is not of the sort expected by the - retain callback, the behavior is undefined. The value is - assigned to the given index, and all values with equal and - larger indices have their indexes increased by one. -*/ -CF_EXPORT -void CFArrayInsertValueAtIndex(CFMutableArrayRef theArray, CFIndex idx, const void *value); - -/*! - @function CFArraySetValueAtIndex - Changes the value with the given index in the array. - @param theArray The array in which the value is to be changed. If this - parameter is not a valid mutable CFArray, the behavior is - undefined. - @param idx The index to which to set the new value. If the index is - outside the index space of the array (0 to N inclusive, - where N is the count of the array before the operation), the - behavior is undefined. If the index is the same as N, this - function has the same effect as CFArrayAppendValue(). - @param value The value to set in the array. The value is retained by - the array using the retain callback provided when the array - was created, and the previous value with that index is - released. If the value is not of the sort expected by the - retain callback, the behavior is undefined. The indices of - other values is not affected. -*/ -CF_EXPORT -void CFArraySetValueAtIndex(CFMutableArrayRef theArray, CFIndex idx, const void *value); - -/*! - @function CFArrayRemoveValueAtIndex - Removes the value with the given index from the array. - @param theArray The array from which the value is to be removed. If - this parameter is not a valid mutable CFArray, the behavior - is undefined. - @param idx The index from which to remove the value. If the index is - outside the index space of the array (0 to N-1 inclusive, - where N is the count of the array before the operation), the - behavior is undefined. -*/ -CF_EXPORT -void CFArrayRemoveValueAtIndex(CFMutableArrayRef theArray, CFIndex idx); - -/*! - @function CFArrayRemoveAllValues - Removes all the values from the array, making it empty. - @param theArray The array from which all of the values are to be - removed. If this parameter is not a valid mutable CFArray, - the behavior is undefined. -*/ -CF_EXPORT -void CFArrayRemoveAllValues(CFMutableArrayRef theArray); - -/*! - @function CFArrayReplaceValues - Replaces a range of values in the array. - @param theArray The array from which all of the values are to be - removed. If this parameter is not a valid mutable CFArray, - the behavior is undefined. - @param range The range of values within the array to replace. If the - range location or end point (defined by the location plus - length minus 1) is outside the index space of the array (0 - to N inclusive, where N is the count of the array), the - behavior is undefined. If the range length is negative, the - behavior is undefined. The range may be empty (length 0), - in which case the new values are merely inserted at the - range location. - @param newValues A C array of the pointer-sized values to be placed - into the array. The new values in the array are ordered in - the same order in which they appear in this C array. This - parameter may be NULL if the newCount parameter is 0. This - C array is not changed or freed by this function. If this - parameter is not a valid pointer to a C array of at least - newCount pointers, the behavior is undefined. - @param newCount The number of values to copy from the values C - array into the CFArray. If this parameter is different than - the range length, the excess newCount values will be - inserted after the range, or the excess range values will be - deleted. This parameter may be 0, in which case no new - values are replaced into the array and the values in the - range are simply removed. If this parameter is negative, or - greater than the number of values actually in the newValues - C array, the behavior is undefined. -*/ -CF_EXPORT -void CFArrayReplaceValues(CFMutableArrayRef theArray, CFRange range, const void **newValues, CFIndex newCount); - -/*! - @function CFArrayExchangeValuesAtIndices - Exchanges the values at two indices of the array. - @param theArray The array of which the values are to be swapped. If - this parameter is not a valid mutable CFArray, the behavior - is undefined. - @param idx1 The first index whose values should be swapped. If the - index is outside the index space of the array (0 to N-1 - inclusive, where N is the count of the array before the - operation), the behavior is undefined. - @param idx2 The second index whose values should be swapped. If the - index is outside the index space of the array (0 to N-1 - inclusive, where N is the count of the array before the - operation), the behavior is undefined. -*/ -CF_EXPORT -void CFArrayExchangeValuesAtIndices(CFMutableArrayRef theArray, CFIndex idx1, CFIndex idx2); - -/*! - @function CFArraySortValues - Sorts the values in the array using the given comparison function. - @param theArray The array whose values are to be sorted. If this - parameter is not a valid mutable CFArray, the behavior is - undefined. - @param range The range of values within the array to sort. If the - range location or end point (defined by the location plus - length minus 1) is outside the index space of the array (0 - to N-1 inclusive, where N is the count of the array), the - behavior is undefined. If the range length is negative, the - behavior is undefined. The range may be empty (length 0). - @param comparator The function with the comparator function type - signature which is used in the sort operation to compare - values in the array with the given value. If this parameter - is not a pointer to a function of the correct prototype, the - the behavior is undefined. If there are values in the array - which the comparator function does not expect or cannot - properly compare, the behavior is undefined. The values in - the range are sorted from least to greatest according to - this function. - @param context A pointer-sized user-defined value, which is passed - as the third parameter to the comparator function, but is - otherwise unused by this function. If the context is not - what is expected by the comparator function, the behavior is - undefined. -*/ -CF_EXPORT -void CFArraySortValues(CFMutableArrayRef theArray, CFRange range, CFComparatorFunction comparator, void *context); - -/*! - @function CFArrayAppendArray - Adds the values from an array to another array. - @param theArray The array to which values from the otherArray are to - be added. If this parameter is not a valid mutable CFArray, - the behavior is undefined. - @param otherArray The array providing the values to be added to the - array. If this parameter is not a valid CFArray, the - behavior is undefined. - @param otherRange The range within the otherArray from which to add - the values to the array. If the range location or end point - (defined by the location plus length minus 1) is outside - the index space of the otherArray (0 to N-1 inclusive, where - N is the count of the otherArray), the behavior is - undefined. The new values are retained by the array using - the retain callback provided when the array was created. If - the values are not of the sort expected by the retain - callback, the behavior is undefined. The values are assigned - to the indices one larger than the previous largest index - in the array, and beyond, and the count of the array is - increased by range.length. The values are assigned new - indices in the array from smallest to largest index in the - order in which they appear in the otherArray. -*/ -CF_EXPORT -void CFArrayAppendArray(CFMutableArrayRef theArray, CFArrayRef otherArray, CFRange otherRange); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFARRAY__ */ - diff --git a/CFArray.h b/CFArray.h new file mode 120000 index 0000000..62cd523 --- /dev/null +++ b/CFArray.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFArray.h \ No newline at end of file diff --git a/CFAttributedString.h b/CFAttributedString.h deleted file mode 100644 index 259a4d4..0000000 --- a/CFAttributedString.h +++ /dev/null @@ -1,40 +0,0 @@ -#if !defined(__COREFOUNDATION_CFATTRIBUTEDSTRING__) -#define __COREFOUNDATION_CFATTRIBUTEDSTRING__ 1 - -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; - -CF_EXPORT CFTypeID CFAttributedStringGetTypeID(void); -CF_EXPORT CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes); -CF_EXPORT CFAttributedStringRef CFAttributedStringCreateWithSubstring(CFAllocatorRef alloc, CFAttributedStringRef aStr, CFRange range); -CF_EXPORT CFAttributedStringRef CFAttributedStringCreateCopy(CFAllocatorRef alloc, CFAttributedStringRef aStr); -CF_EXPORT CFStringRef CFAttributedStringGetString(CFAttributedStringRef aStr); -CF_EXPORT CFIndex CFAttributedStringGetLength(CFAttributedStringRef aStr); -CF_EXPORT CFDictionaryRef CFAttributedStringGetAttributes(CFAttributedStringRef aStr, CFIndex loc, CFRange *effectiveRange); -CF_EXPORT CFTypeRef CFAttributedStringGetAttribute(CFAttributedStringRef aStr, CFIndex loc, CFStringRef attrName, CFRange *effectiveRange); -CF_EXPORT CFDictionaryRef CFAttributedStringGetAttributesAndLongestEffectiveRange(CFAttributedStringRef aStr, CFIndex loc, CFRange inRange, CFRange *longestEffectiveRange); -CF_EXPORT CFTypeRef CFAttributedStringGetAttributeAndLongestEffectiveRange(CFAttributedStringRef aStr, CFIndex loc, CFStringRef attrName, CFRange inRange, CFRange *longestEffectiveRange); -CF_EXPORT CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr); -CF_EXPORT CFMutableAttributedStringRef CFAttributedStringCreateMutable(CFAllocatorRef alloc, CFIndex maxLength); -CF_EXPORT void CFAttributedStringReplaceString(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef replacement); -CF_EXPORT CFMutableStringRef CFAttributedStringGetMutableString(CFMutableAttributedStringRef aStr); -CF_EXPORT void CFAttributedStringSetAttributes(CFMutableAttributedStringRef aStr, CFRange range, CFDictionaryRef replacement, Boolean clearOtherAttributes); -CF_EXPORT void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value); -CF_EXPORT void CFAttributedStringRemoveAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName); -CF_EXPORT void CFAttributedStringReplaceAttributedString(CFMutableAttributedStringRef aStr, CFRange range, CFAttributedStringRef replacement); -CF_EXPORT void CFAttributedStringBeginEditing(CFMutableAttributedStringRef aStr); -CF_EXPORT void CFAttributedStringEndEditing(CFMutableAttributedStringRef aStr); - -CF_EXPORT void _CFAttributedStringSetMutable(CFAttributedStringRef aStr, Boolean isMutable); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif diff --git a/CFAttributedString.h b/CFAttributedString.h new file mode 120000 index 0000000..9fefc6f --- /dev/null +++ b/CFAttributedString.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFAttributedString.h \ No newline at end of file diff --git a/CFAvailability.h b/CFAvailability.h deleted file mode 100644 index 39bd235..0000000 --- a/CFAvailability.h +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFAvailability.h - Copyright (c) 2013-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFAVAILABILITY__) -#define __COREFOUNDATION_CFAVAILABILITY__ 1 - -#include -#include - -#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32) -// Even if unused, these must remain here for compatibility, because projects rely on them being included. -#include -#endif - -#ifndef __has_feature -#define __has_feature(x) 0 -#endif -#ifndef __has_attribute -#define __has_attribute(x) 0 -#endif -#ifndef __has_extension -#define __has_extension(x) 0 -#endif - -// The arguments to these availability macros is a version number, e.g. 10_6, 3_0 or 'NA' -// To use a deprecation message with the macro, add a string as the last argument. -#if __has_feature(attribute_availability_with_message) - -#define __NSi_2_0 introduced=2.0 -#define __NSi_2_1 introduced=2.1 -#define __NSi_2_2 introduced=2.2 -#define __NSi_3_0 introduced=3.0 -#define __NSi_3_1 introduced=3.1 -#define __NSi_3_2 introduced=3.2 -#define __NSi_4_0 introduced=4.0 -#define __NSi_4_1 introduced=4.1 -#define __NSi_4_2 introduced=4.2 -#define __NSi_4_3 introduced=4.3 -#define __NSi_5_0 introduced=5.0 -#define __NSi_5_1 introduced=5.1 -#define __NSi_6_0 introduced=6.0 -#define __NSi_6_1 introduced=6.1 -#define __NSi_7_0 introduced=7.0 -#define __NSi_7_1 introduced=7.1 -#define __NSi_8_0 introduced=8.0 -#define __NSi_8_1 introduced=8.1 -#define __NSi_9_0 introduced=9.0 -#define __NSi_9_1 introduced=9.1 -#define __NSi_10_0 introduced=10.0 -#define __NSi_10_1 introduced=10.1 -#define __NSi_10_2 introduced=10.2 -#define __NSi_10_3 introduced=10.3 -#define __NSi_10_4 introduced=10.4 -#define __NSi_10_5 introduced=10.5 -#define __NSi_10_6 introduced=10.6 -#define __NSi_10_7 introduced=10.7 -#define __NSi_10_8 introduced=10.8 -#define __NSi_10_9 introduced=10.9 -#define __NSi_10_10 introduced=10.10 -#define __NSi_10_10_2 introduced=10.10.2 -#define __NSi_10_10_3 introduced=10.10.3 -#define __NSi_10_11 introduced=10.11 -#define __NSi_10_12 introduced=10.12 - -#define __NSd_2_0 ,deprecated=2.0 -#define __NSd_2_1 ,deprecated=2.1 -#define __NSd_2_2 ,deprecated=2.2 -#define __NSd_3_0 ,deprecated=3.0 -#define __NSd_3_1 ,deprecated=3.1 -#define __NSd_3_2 ,deprecated=3.2 -#define __NSd_4_0 ,deprecated=4.0 -#define __NSd_4_1 ,deprecated=4.1 -#define __NSd_4_2 ,deprecated=4.2 -#define __NSd_4_3 ,deprecated=4.3 -#define __NSd_5_0 ,deprecated=5.0 -#define __NSd_5_1 ,deprecated=5.1 -#define __NSd_6_0 ,deprecated=6.0 -#define __NSd_6_1 ,deprecated=6.1 -#define __NSd_7_0 ,deprecated=7.0 -#define __NSd_7_1 ,deprecated=7.1 -#define __NSd_8_0 ,deprecated=8.0 -#define __NSd_8_1 ,deprecated=8.1 -#define __NSd_9_0 ,deprecated=9.0 -#define __NSd_9_1 ,deprecated=9.1 -#define __NSd_10_0 ,deprecated=10.0 -#define __NSd_10_1 ,deprecated=10.1 -#define __NSd_10_2 ,deprecated=10.2 -#define __NSd_10_3 ,deprecated=10.3 -#define __NSd_10_4 ,deprecated=10.4 -#define __NSd_10_5 ,deprecated=10.5 -#define __NSd_10_6 ,deprecated=10.6 -#define __NSd_10_7 ,deprecated=10.7 -#define __NSd_10_8 ,deprecated=10.8 -#define __NSd_10_9 ,deprecated=10.9 -#define __NSd_10_10 ,deprecated=10.10 -#define __NSd_10_10_2 ,deprecated=10.10.2 -#define __NSd_10_10_3 ,deprecated=10.10.3 -#define __NSd_10_11 ,deprecated=10.11 -#define __NSd_10_12 ,deprecated=10.12 - -#define __NSi_NA unavailable -#define __NSd_NA - -// Do not use TBD as an argument to NS_AVAILABLE -#define __NSi_TBD introduced=9876.5 - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) -// This section is for compilers targeting OS X which support attribute_availability_with_message - -#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(macosx,__NSi_##_mac))) -#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,__NSi_##_mac))) -#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable))) -#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __attribute__((availability(macosx,__NSi_##_macIntro __NSd_##_macDep,message="" __VA_ARGS__))) -#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __attribute__((availability(macosx,__NSi_##_macIntro __NSd_##_macDep,message="" __VA_ARGS__))) -#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __attribute__((availability(macosx,unavailable))) - -#elif (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -// This section is for compilers targeting iOS which support attribute_availability_with_message - -#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,__NSi_##_ios))) -#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(ios,unavailable))) -#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(ios,__NSi_##_ios))) -#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __attribute__((availability(ios,__NSi_##_iosIntro __NSd_##_iosDep,message="" __VA_ARGS__))) -#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __attribute__((availability(ios,unavailable))) -#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __attribute__((availability(ios,__NSi_##_iosIntro __NSd_##_iosDep,message="" __VA_ARGS__))) - -#endif - -#elif (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -// This section is for OS X or iOS, and compilers without support for attribute_availability_with_message. We fall back to Availability.h. - -#ifndef __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 -#define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 __AVAILABILITY_INTERNAL_DEPRECATED -#endif - -#define CF_AVAILABLE(_mac, _ios) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_##_ios) -#define CF_AVAILABLE_MAC(_mac) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_NA) -#define CF_AVAILABLE_IOS(_ios) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_##_ios) -#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_##_macIntro, __MAC_##_macDep, __IPHONE_##_iosIntro, __IPHONE_##_iosDep) -#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_##_macIntro, __MAC_##_macDep, __IPHONE_NA, __IPHONE_NA) -#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_##_iosIntro, __IPHONE_##_iosDep) - -#endif // __has_feature(attribute_availability_with_message) - -#ifndef CF_AVAILABLE -// This section is for platforms which do not support availability -#define CF_AVAILABLE(_mac, _ios) -#define CF_AVAILABLE_MAC(_mac) -#define CF_AVAILABLE_IOS(_ios) -#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) -#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) -#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) -#endif - -// Older versions of these macros; use iOS versions instead -#define CF_AVAILABLE_IPHONE(_ios) CF_AVAILABLE_IOS(_ios) -#define CF_DEPRECATED_IPHONE(_iosIntro, _iosDep) CF_DEPRECATED_IOS(_iosIntro, _iosDep) - -// Enum availability macros -#if __has_feature(enumerator_attributes) && __has_attribute(availability) -#define CF_ENUM_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios) -#define CF_ENUM_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac) -#define CF_ENUM_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios) -#define CF_ENUM_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, __VA_ARGS__) -#define CF_ENUM_DEPRECATED_MAC(_macIntro, _macDep, ...) CF_DEPRECATED_MAC(_macIntro, _macDep, __VA_ARGS__) -#define CF_ENUM_DEPRECATED_IOS(_iosIntro, _iosDep, ...) CF_DEPRECATED_IOS(_iosIntro, _iosDep, __VA_ARGS__) -#else -#define CF_ENUM_AVAILABLE(_mac, _ios) -#define CF_ENUM_AVAILABLE_MAC(_mac) -#define CF_ENUM_AVAILABLE_IOS(_ios) -#define CF_ENUM_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) -#define CF_ENUM_DEPRECATED_MAC(_macIntro, _macDep, ...) -#define CF_ENUM_DEPRECATED_IOS(_iosIntro, _iosDep, ...) -#endif - -// Enums and Options -// Enums and Options -#define __CF_ENUM_GET_MACRO(_1, _2, NAME, ...) NAME -#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum)) -#define __CF_NAMED_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -#define __CF_ANON_ENUM(_type) enum : _type -#if (__cplusplus) -#define CF_OPTIONS(_type, _name) _type _name; enum : _type -#else -#define CF_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type -#endif -#else -#define __CF_NAMED_ENUM(_type, _name) _type _name; enum -#define __CF_ANON_ENUM(_type) enum -#define CF_OPTIONS(_type, _name) _type _name; enum -#endif - -/* CF_ENUM supports the use of one or two arguments. The first argument is always the integer type used for the values of the enum. The second argument is an optional type name for the macro. When specifying a type name, you must precede the macro with 'typedef' like so: -typedef CF_ENUM(CFIndex, CFComparisonResult) { - ... -}; -If you do not specify a type name, do not use 'typdef', like so: -CF_ENUM(CFIndex) { - ... -}; -*/ -#define CF_ENUM(...) __CF_ENUM_GET_MACRO(__VA_ARGS__, __CF_NAMED_ENUM, __CF_ANON_ENUM, )(__VA_ARGS__) - -// Extension availability macros -#define CF_EXTENSION_UNAVAILABLE(_msg) __OS_EXTENSION_UNAVAILABLE(_msg) -#define CF_EXTENSION_UNAVAILABLE_MAC(_msg) __OSX_EXTENSION_UNAVAILABLE(_msg) -#define CF_EXTENSION_UNAVAILABLE_IOS(_msg) __IOS_EXTENSION_UNAVAILABLE(_msg) - -#endif // __COREFOUNDATION_CFAVAILABILITY__ diff --git a/CFAvailability.h b/CFAvailability.h new file mode 120000 index 0000000..6ca4a95 --- /dev/null +++ b/CFAvailability.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFAvailability.h \ No newline at end of file diff --git a/CFBag.h b/CFBag.h deleted file mode 100644 index 41734e1..0000000 --- a/CFBag.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBag.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFBAG__) -#define __COREFOUNDATION_CFBAG__ 1 - -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef const void * (*CFBagRetainCallBack)(CFAllocatorRef allocator, const void *value); -typedef void (*CFBagReleaseCallBack)(CFAllocatorRef allocator, const void *value); -typedef CFStringRef (*CFBagCopyDescriptionCallBack)(const void *value); -typedef Boolean (*CFBagEqualCallBack)(const void *value1, const void *value2); -typedef CFHashCode (*CFBagHashCallBack)(const void *value); -typedef struct { - CFIndex version; - CFBagRetainCallBack retain; - CFBagReleaseCallBack release; - CFBagCopyDescriptionCallBack copyDescription; - CFBagEqualCallBack equal; - CFBagHashCallBack hash; -} CFBagCallBacks; - -CF_EXPORT -const CFBagCallBacks kCFTypeBagCallBacks; -CF_EXPORT -const CFBagCallBacks kCFCopyStringBagCallBacks; - -typedef void (*CFBagApplierFunction)(const void *value, void *context); - -typedef const struct __CFBag * CFBagRef; -typedef struct __CFBag * CFMutableBagRef; - -CF_EXPORT -CFTypeID CFBagGetTypeID(void); - -CF_EXPORT -CFBagRef CFBagCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFBagCallBacks *callBacks); - -CF_EXPORT -CFBagRef CFBagCreateCopy(CFAllocatorRef allocator, CFBagRef theBag); - -CF_EXPORT -CFMutableBagRef CFBagCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFBagCallBacks *callBacks); - -CF_EXPORT -CFMutableBagRef CFBagCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFBagRef theBag); - -CF_EXPORT -CFIndex CFBagGetCount(CFBagRef theBag); - -CF_EXPORT -CFIndex CFBagGetCountOfValue(CFBagRef theBag, const void *value); - -CF_EXPORT -Boolean CFBagContainsValue(CFBagRef theBag, const void *value); - -CF_EXPORT -const void *CFBagGetValue(CFBagRef theBag, const void *value); - -CF_EXPORT -Boolean CFBagGetValueIfPresent(CFBagRef theBag, const void *candidate, const void **value); - -CF_EXPORT -void CFBagGetValues(CFBagRef theBag, const void **values); - -CF_EXPORT -void CFBagApplyFunction(CFBagRef theBag, CFBagApplierFunction applier, void *context); - -CF_EXPORT -void CFBagAddValue(CFMutableBagRef theBag, const void *value); - -CF_EXPORT -void CFBagReplaceValue(CFMutableBagRef theBag, const void *value); - -CF_EXPORT -void CFBagSetValue(CFMutableBagRef theBag, const void *value); - -CF_EXPORT -void CFBagRemoveValue(CFMutableBagRef theBag, const void *value); - -CF_EXPORT -void CFBagRemoveAllValues(CFMutableBagRef theBag); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFBAG__ */ - diff --git a/CFBag.h b/CFBag.h new file mode 120000 index 0000000..d8a4e49 --- /dev/null +++ b/CFBag.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBag.h \ No newline at end of file diff --git a/CFBase.h b/CFBase.h deleted file mode 100644 index ac02d9b..0000000 --- a/CFBase.h +++ /dev/null @@ -1,618 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBase.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFBASE__) -#define __COREFOUNDATION_CFBASE__ 1 - -#include -#include - -#if (defined(__CYGWIN32__) || defined(_WIN32)) && !defined(__WIN32__) -#define __WIN32__ 1 -#endif - -#if defined(_WIN64) && !defined(__WIN64__) -#define __WIN64__ 1 -#endif - -#if defined(__WIN64__) && !defined(__LLP64__) -#define __LLP64__ 1 -#endif - -#if defined(_MSC_VER) && defined(_M_IX86) -#define __i386__ 1 -#endif - -#if (defined(__i386__) || defined(__x86_64__)) && !defined(__LITTLE_ENDIAN__) -#define __LITTLE_ENDIAN__ 1 -#endif - -#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) -#error Do not know the endianess of this architecture -#endif - -#if !__BIG_ENDIAN__ && !__LITTLE_ENDIAN__ -#error Both __BIG_ENDIAN__ and __LITTLE_ENDIAN__ cannot be false -#endif - -#if __BIG_ENDIAN__ && __LITTLE_ENDIAN__ -#error Both __BIG_ENDIAN__ and __LITTLE_ENDIAN__ cannot be true -#endif - -// Some compilers provide the capability to test if certain features are available. This macro provides a compatibility path for other compilers. -#ifndef __has_feature -#define __has_feature(x) 0 -#endif - -// Some compilers provide the capability to test if certain attributes are available. This macro provides a compatibility path for other compilers. -#ifndef __has_attribute -#define __has_attribute(x) 0 -#endif - -#ifndef __has_extension -#define __has_extension(x) 0 -#endif - -#if defined(__GNUC__) || TARGET_OS_WIN32 -#include -#include -#endif - -#if __BLOCKS__ -#include -#endif - - #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) - #include - #endif - -#if !defined(__MACTYPES__) -#if !defined(_OS_OSTYPES_H) - typedef unsigned char Boolean; - typedef unsigned char UInt8; - typedef signed char SInt8; - typedef unsigned short UInt16; - typedef signed short SInt16; - typedef unsigned int UInt32; - typedef signed int SInt32; - typedef uint64_t UInt64; - typedef int64_t SInt64; - typedef SInt32 OSStatus; -#endif - typedef float Float32; - typedef double Float64; - typedef unsigned short UniChar; - typedef unsigned long UniCharCount; - typedef unsigned char * StringPtr; - typedef const unsigned char * ConstStringPtr; - typedef unsigned char Str255[256]; - typedef const unsigned char * ConstStr255Param; - typedef SInt16 OSErr; - typedef SInt16 RegionCode; - typedef SInt16 LangCode; - typedef SInt16 ScriptCode; - typedef UInt32 FourCharCode; - typedef FourCharCode OSType; - typedef UInt8 Byte; - typedef SInt8 SignedByte; -#endif -#if !defined(__MACTYPES__) || (defined(UNIVERSAL_INTERFACES_VERSION) && UNIVERSAL_INTERFACES_VERSION < 0x0340) - typedef UInt32 UTF32Char; - typedef UInt16 UTF16Char; - typedef UInt8 UTF8Char; -#endif - -#if !defined(CF_EXTERN_C_BEGIN) -#if defined(__cplusplus) -#define CF_EXTERN_C_BEGIN extern "C" { -#define CF_EXTERN_C_END } -#else -#define CF_EXTERN_C_BEGIN -#define CF_EXTERN_C_END -#endif -#endif - -#if TARGET_OS_WIN32 - -#if !defined(CF_EXPORT) -#if defined(CF_BUILDING_CF) && defined(__cplusplus) -#define CF_EXPORT extern "C" __declspec(dllexport) -#elif defined(CF_BUILDING_CF) && !defined(__cplusplus) -#define CF_EXPORT extern __declspec(dllexport) -#elif defined(__cplusplus) -#define CF_EXPORT extern "C" __declspec(dllimport) -#else -#define CF_EXPORT extern __declspec(dllimport) -#endif -#endif - -#else -#define CF_EXPORT extern -#endif - -CF_EXTERN_C_BEGIN - -#if !defined(NULL) -#if defined(__GNUG__) - #define NULL __null -#elif defined(__cplusplus) - #define NULL 0 -#else - #define NULL ((void *)0) -#endif -#endif - -#if !defined(TRUE) - #define TRUE 1 -#endif - -#if !defined(FALSE) - #define FALSE 0 -#endif - -#if !defined(CF_INLINE) - #if defined(__GNUC__) && (__GNUC__ == 4) && !defined(DEBUG) - #define CF_INLINE static __inline__ __attribute__((always_inline)) - #elif defined(__GNUC__) - #define CF_INLINE static __inline__ - #elif defined(__cplusplus) - #define CF_INLINE static inline - #elif defined(_MSC_VER) - #define CF_INLINE static __inline - #elif TARGET_OS_WIN32 - #define CF_INLINE static __inline__ - #endif -#endif - -#define CF_ASSUME_NONNULL_BEGIN -#define CF_ASSUME_NONNULL_END - -// Marks functions which return a CF type that needs to be released by the caller but whose names are not consistent with CoreFoundation naming rules. The recommended fix to this is to rename the functions, but this macro can be used to let the clang static analyzer know of any exceptions that cannot be fixed. -// This macro is ONLY to be used in exceptional circumstances, not to annotate functions which conform to the CoreFoundation naming rules. -#ifndef CF_RETURNS_RETAINED -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#else -#define CF_RETURNS_RETAINED -#endif -#endif - -// Marks functions which return a CF type that may need to be retained by the caller but whose names are not consistent with CoreFoundation naming rules. The recommended fix to this is to rename the functions, but this macro can be used to let the clang static analyzer know of any exceptions that cannot be fixed. -// This macro is ONLY to be used in exceptional circumstances, not to annotate functions which conform to the CoreFoundation naming rules. -#ifndef CF_RETURNS_NOT_RETAINED -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#else -#define CF_RETURNS_NOT_RETAINED -#endif -#endif - -// Marks function arguments which are released by the callee. -#ifndef CF_RELEASES_ARGUMENT -#if __has_feature(attribute_cf_consumed) -#define CF_RELEASES_ARGUMENT __attribute__((cf_consumed)) -#else -#define CF_RELEASES_ARGUMENT -#endif -#endif - -// Compatibility -#ifndef CF_CONSUMED -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#else -#define CF_CONSUMED -#endif -#endif - -// Marks functions which cannot be used when compiling in automatic reference counting mode. -#if __has_feature(objc_arc) -#define CF_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -#else -#define CF_AUTOMATED_REFCOUNT_UNAVAILABLE -#endif - -#ifndef CF_IMPLICIT_BRIDGING_ENABLED -#if __has_feature(arc_cf_code_audited) -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") -#else -#define CF_IMPLICIT_BRIDGING_ENABLED -#endif -#endif - -#ifndef CF_IMPLICIT_BRIDGING_DISABLED -#if __has_feature(arc_cf_code_audited) -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") -#else -#define CF_IMPLICIT_BRIDGING_DISABLED -#endif -#endif - -#if __has_attribute(objc_bridge) - -#ifdef __OBJC__ -@class NSArray; -@class NSAttributedString; -@class NSString; -@class NSNull; -@class NSCharacterSet; -@class NSData; -@class NSDate; -@class NSTimeZone; -@class NSDictionary; -@class NSError; -@class NSLocale; -@class NSNumber; -@class NSNumber; -@class NSSet; -@class NSURL; -#endif - -#define CF_BRIDGED_TYPE(T) __attribute__((objc_bridge(T))) -#define CF_BRIDGED_MUTABLE_TYPE(T) __attribute__((objc_bridge_mutable(T))) -#define CF_RELATED_TYPE(T,C,I) __attribute__((objc_bridge_related(T,C,I))) -#else -#define CF_BRIDGED_TYPE(T) -#define CF_BRIDGED_MUTABLE_TYPE(T) -#define CF_RELATED_TYPE(T,C,I) -#endif - - -CF_EXPORT double kCFCoreFoundationVersionNumber; - -#if TARGET_OS_MAC -#define kCFCoreFoundationVersionNumber10_0 196.40 -#define kCFCoreFoundationVersionNumber10_0_3 196.50 -#define kCFCoreFoundationVersionNumber10_1 226.00 -#define kCFCoreFoundationVersionNumber10_1_1 226.00 -/* Note the next three do not follow the usual numbering policy from the base release */ -#define kCFCoreFoundationVersionNumber10_1_2 227.20 -#define kCFCoreFoundationVersionNumber10_1_3 227.20 -#define kCFCoreFoundationVersionNumber10_1_4 227.30 -#define kCFCoreFoundationVersionNumber10_2 263.00 -#define kCFCoreFoundationVersionNumber10_2_1 263.10 -#define kCFCoreFoundationVersionNumber10_2_2 263.10 -#define kCFCoreFoundationVersionNumber10_2_3 263.30 -#define kCFCoreFoundationVersionNumber10_2_4 263.30 -#define kCFCoreFoundationVersionNumber10_2_5 263.50 -#define kCFCoreFoundationVersionNumber10_2_6 263.50 -#define kCFCoreFoundationVersionNumber10_2_7 263.50 -#define kCFCoreFoundationVersionNumber10_2_8 263.50 -#define kCFCoreFoundationVersionNumber10_3 299.00 -#define kCFCoreFoundationVersionNumber10_3_1 299.00 -#define kCFCoreFoundationVersionNumber10_3_2 299.00 -#define kCFCoreFoundationVersionNumber10_3_3 299.30 -#define kCFCoreFoundationVersionNumber10_3_4 299.31 -#define kCFCoreFoundationVersionNumber10_3_5 299.31 -#define kCFCoreFoundationVersionNumber10_3_6 299.32 -#define kCFCoreFoundationVersionNumber10_3_7 299.33 -#define kCFCoreFoundationVersionNumber10_3_8 299.33 -#define kCFCoreFoundationVersionNumber10_3_9 299.35 -#define kCFCoreFoundationVersionNumber10_4 368.00 -#define kCFCoreFoundationVersionNumber10_4_1 368.10 -#define kCFCoreFoundationVersionNumber10_4_2 368.11 -#define kCFCoreFoundationVersionNumber10_4_3 368.18 -#define kCFCoreFoundationVersionNumber10_4_4_Intel 368.26 -#define kCFCoreFoundationVersionNumber10_4_4_PowerPC 368.25 -#define kCFCoreFoundationVersionNumber10_4_5_Intel 368.26 -#define kCFCoreFoundationVersionNumber10_4_5_PowerPC 368.25 -#define kCFCoreFoundationVersionNumber10_4_6_Intel 368.26 -#define kCFCoreFoundationVersionNumber10_4_6_PowerPC 368.25 -#define kCFCoreFoundationVersionNumber10_4_7 368.27 -#define kCFCoreFoundationVersionNumber10_4_8 368.27 -#define kCFCoreFoundationVersionNumber10_4_9 368.28 -#define kCFCoreFoundationVersionNumber10_4_10 368.28 -#define kCFCoreFoundationVersionNumber10_4_11 368.31 -#define kCFCoreFoundationVersionNumber10_5 476.00 -#define kCFCoreFoundationVersionNumber10_5_1 476.00 -#define kCFCoreFoundationVersionNumber10_5_2 476.10 -#define kCFCoreFoundationVersionNumber10_5_3 476.13 -#define kCFCoreFoundationVersionNumber10_5_4 476.14 -#define kCFCoreFoundationVersionNumber10_5_5 476.15 -#define kCFCoreFoundationVersionNumber10_5_6 476.17 -#define kCFCoreFoundationVersionNumber10_5_7 476.18 -#define kCFCoreFoundationVersionNumber10_5_8 476.19 -#define kCFCoreFoundationVersionNumber10_6 550.00 -#define kCFCoreFoundationVersionNumber10_6_1 550.00 -#define kCFCoreFoundationVersionNumber10_6_2 550.13 -#define kCFCoreFoundationVersionNumber10_6_3 550.19 -#define kCFCoreFoundationVersionNumber10_6_4 550.29 -#define kCFCoreFoundationVersionNumber10_6_5 550.42 -#define kCFCoreFoundationVersionNumber10_6_6 550.42 -#define kCFCoreFoundationVersionNumber10_6_7 550.42 -#define kCFCoreFoundationVersionNumber10_6_8 550.43 -#define kCFCoreFoundationVersionNumber10_7 635.00 -#define kCFCoreFoundationVersionNumber10_7_1 635.00 -#define kCFCoreFoundationVersionNumber10_7_2 635.15 -#define kCFCoreFoundationVersionNumber10_7_3 635.19 -#define kCFCoreFoundationVersionNumber10_7_4 635.21 -#define kCFCoreFoundationVersionNumber10_7_5 635.21 -#define kCFCoreFoundationVersionNumber10_8 744.00 -#define kCFCoreFoundationVersionNumber10_8_1 744.00 -#define kCFCoreFoundationVersionNumber10_8_2 744.12 -#define kCFCoreFoundationVersionNumber10_8_3 744.18 -#define kCFCoreFoundationVersionNumber10_8_4 744.19 -#define kCFCoreFoundationVersionNumber10_9 855.11 -#define kCFCoreFoundationVersionNumber10_9_1 855.11 -#define kCFCoreFoundationVersionNumber10_9_2 855.14 -#endif - -#if TARGET_OS_IPHONE -#define kCFCoreFoundationVersionNumber_iPhoneOS_2_0 478.23 -#define kCFCoreFoundationVersionNumber_iPhoneOS_2_1 478.26 -#define kCFCoreFoundationVersionNumber_iPhoneOS_2_2 478.29 -#define kCFCoreFoundationVersionNumber_iPhoneOS_3_0 478.47 -#define kCFCoreFoundationVersionNumber_iPhoneOS_3_1 478.52 -#define kCFCoreFoundationVersionNumber_iPhoneOS_3_2 478.61 -#define kCFCoreFoundationVersionNumber_iOS_4_0 550.32 -#define kCFCoreFoundationVersionNumber_iOS_4_1 550.38 -#define kCFCoreFoundationVersionNumber_iOS_4_2 550.52 -#define kCFCoreFoundationVersionNumber_iOS_4_3 550.52 -#define kCFCoreFoundationVersionNumber_iOS_5_0 675.00 -#define kCFCoreFoundationVersionNumber_iOS_5_1 690.10 -#define kCFCoreFoundationVersionNumber_iOS_6_0 793.00 -#define kCFCoreFoundationVersionNumber_iOS_6_1 793.00 -#define kCFCoreFoundationVersionNumber_iOS_7_0 847.20 -#define kCFCoreFoundationVersionNumber_iOS_7_1 847.24 -#endif - -#if __LLP64__ -typedef unsigned long long CFTypeID; -typedef unsigned long long CFOptionFlags; -typedef unsigned long long CFHashCode; -typedef signed long long CFIndex; -#else -typedef unsigned long CFTypeID; -typedef unsigned long CFOptionFlags; -typedef unsigned long CFHashCode; -typedef signed long CFIndex; -#endif - -/* Base "type" of all "CF objects", and polymorphic functions on them */ -typedef const void * CFTypeRef; - -typedef const struct CF_BRIDGED_TYPE(NSString) __CFString * CFStringRef; -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableString) __CFString * CFMutableStringRef; - -/* - Type to mean any instance of a property list type; - currently, CFString, CFData, CFNumber, CFBoolean, CFDate, - CFArray, and CFDictionary. -*/ -typedef CFTypeRef CFPropertyListRef; - -/* Values returned from comparison functions */ -typedef CF_ENUM(CFIndex, CFComparisonResult) { - kCFCompareLessThan = -1L, - kCFCompareEqualTo = 0, - kCFCompareGreaterThan = 1 -}; - -/* A standard comparison function */ -typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context); - -/* Constant used by some functions to indicate failed searches. */ -/* This is of type CFIndex. */ -enum { - kCFNotFound = -1 -}; - - -/* Range type */ -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; - -#if defined(CF_INLINE) -CF_INLINE CFRange CFRangeMake(CFIndex loc, CFIndex len) { - CFRange range; - range.location = loc; - range.length = len; - return range; -} -#else -#define CFRangeMake(LOC, LEN) __CFRangeMake(LOC, LEN) -#endif - -/* Private; do not use */ -CF_EXPORT -CFRange __CFRangeMake(CFIndex loc, CFIndex len); - - -/* Null representant */ - -typedef const struct CF_BRIDGED_TYPE(NSNull) __CFNull * CFNullRef; - -CF_EXPORT -CFTypeID CFNullGetTypeID(void); - -CF_EXPORT -const CFNullRef kCFNull; // the singleton null instance - - -/* Allocator API - - Most of the time when specifying an allocator to Create functions, the NULL - argument indicates "use the default"; this is the same as using kCFAllocatorDefault - or the return value from CFAllocatorGetDefault(). This assures that you will use - the allocator in effect at that time. -*/ -typedef const struct __CFAllocator * CFAllocatorRef; - -/* This is a synonym for NULL, if you'd rather use a named constant. */ -CF_EXPORT -const CFAllocatorRef kCFAllocatorDefault; - -/* Default system allocator; you rarely need to use this. */ -CF_EXPORT -const CFAllocatorRef kCFAllocatorSystemDefault; - -/* This allocator uses malloc(), realloc(), and free(). This should not be - generally used; stick to kCFAllocatorDefault whenever possible. This - allocator is useful as the "bytesDeallocator" in CFData or - "contentsDeallocator" in CFString where the memory was obtained as a - result of malloc() type functions. -*/ -CF_EXPORT -const CFAllocatorRef kCFAllocatorMalloc; - -/* This allocator explicitly uses the default malloc zone, returned by - malloc_default_zone(). It should only be used when an object is - safe to be allocated in non-scanned memory. - */ -CF_EXPORT -const CFAllocatorRef kCFAllocatorMallocZone; - -/* Null allocator which does nothing and allocates no memory. This allocator - is useful as the "bytesDeallocator" in CFData or "contentsDeallocator" - in CFString where the memory should not be freed. -*/ -CF_EXPORT -const CFAllocatorRef kCFAllocatorNull; - -/* Special allocator argument to CFAllocatorCreate() which means - "use the functions given in the context to allocate the allocator - itself as well". -*/ -CF_EXPORT -const CFAllocatorRef kCFAllocatorUseContext; - -typedef const void * (*CFAllocatorRetainCallBack)(const void *info); -typedef void (*CFAllocatorReleaseCallBack)(const void *info); -typedef CFStringRef (*CFAllocatorCopyDescriptionCallBack)(const void *info); -typedef void * (*CFAllocatorAllocateCallBack)(CFIndex allocSize, CFOptionFlags hint, void *info); -typedef void * (*CFAllocatorReallocateCallBack)(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info); -typedef void (*CFAllocatorDeallocateCallBack)(void *ptr, void *info); -typedef CFIndex (*CFAllocatorPreferredSizeCallBack)(CFIndex size, CFOptionFlags hint, void *info); -typedef struct { - CFIndex version; - void * info; - CFAllocatorRetainCallBack retain; - CFAllocatorReleaseCallBack release; - CFAllocatorCopyDescriptionCallBack copyDescription; - CFAllocatorAllocateCallBack allocate; - CFAllocatorReallocateCallBack reallocate; - CFAllocatorDeallocateCallBack deallocate; - CFAllocatorPreferredSizeCallBack preferredSize; -} CFAllocatorContext; - -CF_EXPORT -CFTypeID CFAllocatorGetTypeID(void); - -/* - CFAllocatorSetDefault() sets the allocator that is used in the current - thread whenever NULL is specified as an allocator argument. This means - that most, if not all allocations will go through this allocator. It - also means that any allocator set as the default needs to be ready to - deal with arbitrary memory allocation requests; in addition, the size - and number of requests will change between releases. - - An allocator set as the default will never be released, even if later - another allocator replaces it as the default. Not only is it impractical - for it to be released (as there might be caches created under the covers - that refer to the allocator), in general it's also safer and more - efficient to keep it around. - - If you wish to use a custom allocator in a context, it's best to provide - it as the argument to the various creation functions rather than setting - it as the default. Setting the default allocator is not encouraged. - - If you do set an allocator as the default, either do it for all time in - your app, or do it in a nested fashion (by restoring the previous allocator - when you exit your context). The latter might be appropriate for plug-ins - or libraries that wish to set the default allocator. -*/ -CF_EXPORT -void CFAllocatorSetDefault(CFAllocatorRef allocator); - -CF_EXPORT -CFAllocatorRef CFAllocatorGetDefault(void); - -CF_EXPORT -CFAllocatorRef CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorContext *context); - -CF_EXPORT -void *CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint); - -CF_EXPORT -void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint); - -CF_EXPORT -void CFAllocatorDeallocate(CFAllocatorRef allocator, void *ptr); - -CF_EXPORT -CFIndex CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint); - -CF_EXPORT -void CFAllocatorGetContext(CFAllocatorRef allocator, CFAllocatorContext *context); - - -/* Polymorphic CF functions */ - -CF_IMPLICIT_BRIDGING_ENABLED - -CF_EXPORT -CFTypeID CFGetTypeID(CFTypeRef cf); - -CF_EXPORT -CFStringRef CFCopyTypeIDDescription(CFTypeID type_id); - -CF_EXPORT -CFTypeRef CFRetain(CFTypeRef cf); - -CF_EXPORT -void CFRelease(CFTypeRef cf); - -CF_EXPORT -CFTypeRef CFAutorelease(CFTypeRef CF_RELEASES_ARGUMENT arg) CF_AVAILABLE(10_9, 7_0); - -CF_EXPORT -CFIndex CFGetRetainCount(CFTypeRef cf); - -CF_EXPORT -Boolean CFEqual(CFTypeRef cf1, CFTypeRef cf2); - -CF_EXPORT -CFHashCode CFHash(CFTypeRef cf); - -CF_EXPORT -CFStringRef CFCopyDescription(CFTypeRef cf); - -CF_EXPORT -CFAllocatorRef CFGetAllocator(CFTypeRef cf); - -CF_IMPLICIT_BRIDGING_DISABLED - -// This function is unavailable in ARC mode. -CF_EXPORT -CFTypeRef CFMakeCollectable(CFTypeRef cf) CF_AUTOMATED_REFCOUNT_UNAVAILABLE; - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFBASE__ */ - diff --git a/CFBase.h b/CFBase.h new file mode 120000 index 0000000..9a79f58 --- /dev/null +++ b/CFBase.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBase.h \ No newline at end of file diff --git a/CFBasicHash.h b/CFBasicHash.h deleted file mode 100644 index 30a8895..0000000 --- a/CFBasicHash.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBasicHash.h - Copyright (c) 2008-2014, Apple Inc. All rights reserved. -*/ - -#include -#include -#include "CFInternal.h" - -CF_EXTERN_C_BEGIN - -struct __objcFastEnumerationStateEquivalent2 { - unsigned long state; - unsigned long *itemsPtr; - unsigned long *mutationsPtr; - unsigned long extra[5]; -}; - -enum { - __kCFBasicHashLinearHashingValue = 1, - __kCFBasicHashDoubleHashingValue = 2, - __kCFBasicHashExponentialHashingValue = 3, -}; - -enum { - kCFBasicHashHasKeys = (1UL << 0), - kCFBasicHashHasCounts = (1UL << 1), - kCFBasicHashHasHashCache = (1UL << 2), - - kCFBasicHashIntegerValues = (1UL << 6), - kCFBasicHashIntegerKeys = (1UL << 7), - - kCFBasicHashStrongValues = (1UL << 8), - kCFBasicHashStrongKeys = (1UL << 9), - - kCFBasicHashWeakValues = (1UL << 10), - kCFBasicHashWeakKeys = (1UL << 11), - - kCFBasicHashIndirectKeys = (1UL << 12), - - kCFBasicHashLinearHashing = (__kCFBasicHashLinearHashingValue << 13), // bits 13-14 - kCFBasicHashDoubleHashing = (__kCFBasicHashDoubleHashingValue << 13), - kCFBasicHashExponentialHashing = (__kCFBasicHashExponentialHashingValue << 13), - - kCFBasicHashAggressiveGrowth = (1UL << 15), -}; - -// Note that for a hash table without keys, the value is treated as the key, -// and the value should be passed in as the key for operations which take a key. - -typedef struct { - CFIndex idx; - uintptr_t weak_key; - uintptr_t weak_value; - uintptr_t count; -} CFBasicHashBucket; - -typedef struct __CFBasicHash *CFBasicHashRef; -typedef const struct __CFBasicHash *CFConstBasicHashRef; - -// Bit 6 in the CF_INFO_BITS of the CFRuntimeBase inside the CFBasicHashRef is the "is immutable" bit -CF_INLINE Boolean CFBasicHashIsMutable(CFConstBasicHashRef ht) { - return __CFBitfieldGetValue(((CFRuntimeBase *)ht)->_cfinfo[CF_INFO_BITS], 6, 6) ? false : true; -} - -CF_INLINE void CFBasicHashMakeImmutable(CFBasicHashRef ht) { - __CFBitfieldSetValue(((CFRuntimeBase *)ht)->_cfinfo[CF_INFO_BITS], 6, 6, 1); -} - - -typedef struct __CFBasicHashCallbacks CFBasicHashCallbacks; - -struct __CFBasicHashCallbacks { - uintptr_t (*retainValue)(CFAllocatorRef alloc, uintptr_t stack_value); // Return 2nd arg or new value - uintptr_t (*retainKey)(CFAllocatorRef alloc, uintptr_t stack_key); // Return 2nd arg or new key - void (*releaseValue)(CFAllocatorRef alloc, uintptr_t stack_value); - void (*releaseKey)(CFAllocatorRef alloc, uintptr_t stack_key); - 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 - Boolean (*equateKeys)(uintptr_t coll_key1, uintptr_t stack_key2); // 1st arg is in-collection key, 2nd arg is probe parameter - CFHashCode (*hashKey)(uintptr_t stack_key); - uintptr_t (*getIndirectKey)(uintptr_t coll_value); // Return key; 1st arg is in-collection value - CFStringRef (*copyValueDescription)(uintptr_t stack_value); - CFStringRef (*copyKeyDescription)(uintptr_t stack_key); -}; - -Boolean CFBasicHashHasStrongValues(CFConstBasicHashRef ht); -Boolean CFBasicHashHasStrongKeys(CFConstBasicHashRef ht); - -CFOptionFlags CFBasicHashGetFlags(CFConstBasicHashRef ht); -CFIndex CFBasicHashGetNumBuckets(CFConstBasicHashRef ht); -CFIndex CFBasicHashGetCapacity(CFConstBasicHashRef ht); -void CFBasicHashSetCapacity(CFBasicHashRef ht, CFIndex capacity); - -CFIndex CFBasicHashGetCount(CFConstBasicHashRef ht); -CFBasicHashBucket CFBasicHashGetBucket(CFConstBasicHashRef ht, CFIndex idx); -CFBasicHashBucket CFBasicHashFindBucket(CFConstBasicHashRef ht, uintptr_t stack_key); -CFIndex CFBasicHashGetCountOfKey(CFConstBasicHashRef ht, uintptr_t stack_key); -CFIndex CFBasicHashGetCountOfValue(CFConstBasicHashRef ht, uintptr_t stack_value); -Boolean CFBasicHashesAreEqual(CFConstBasicHashRef ht1, CFConstBasicHashRef ht2); -void CFBasicHashApply(CFConstBasicHashRef ht, Boolean (^block)(CFBasicHashBucket)); -void CFBasicHashApplyIndexed(CFConstBasicHashRef ht, CFRange range, Boolean (^block)(CFBasicHashBucket)); -void CFBasicHashGetElements(CFConstBasicHashRef ht, CFIndex bufferslen, uintptr_t *weak_values, uintptr_t *weak_keys); - -Boolean CFBasicHashAddValue(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t stack_value); -void CFBasicHashReplaceValue(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t stack_value); -void CFBasicHashSetValue(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t stack_value); -CFIndex CFBasicHashRemoveValue(CFBasicHashRef ht, uintptr_t stack_key); -CFIndex CFBasicHashRemoveValueAtIndex(CFBasicHashRef ht, CFIndex idx); -void CFBasicHashRemoveAllValues(CFBasicHashRef ht); - -Boolean CFBasicHashAddIntValueAndInc(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t int_value); -void CFBasicHashRemoveIntValueAndDec(CFBasicHashRef ht, uintptr_t int_value); - -size_t CFBasicHashGetSize(CFConstBasicHashRef ht, Boolean total); -void CFBasicHashSuppressRC(CFBasicHashRef ht); -void CFBasicHashUnsuppressRC(CFBasicHashRef ht); - -CFStringRef CFBasicHashCopyDescription(CFConstBasicHashRef ht, Boolean detailed, CFStringRef linePrefix, CFStringRef entryLinePrefix, Boolean describeElements); - -CFTypeID CFBasicHashGetTypeID(void); - -extern Boolean __CFBasicHashEqual(CFTypeRef cf1, CFTypeRef cf2); -extern CFHashCode __CFBasicHashHash(CFTypeRef cf); -extern CFStringRef __CFBasicHashCopyDescription(CFTypeRef cf); -extern void __CFBasicHashDeallocate(CFTypeRef cf); -extern unsigned long __CFBasicHashFastEnumeration(CFConstBasicHashRef ht, struct __objcFastEnumerationStateEquivalent2 *state, void *stackbuffer, unsigned long count); - -// creation functions create mutable CFBasicHashRefs -CFBasicHashRef CFBasicHashCreate(CFAllocatorRef allocator, CFOptionFlags flags, const CFBasicHashCallbacks *cb); -CFBasicHashRef CFBasicHashCreateCopy(CFAllocatorRef allocator, CFConstBasicHashRef ht); - - -CF_EXTERN_C_END - diff --git a/CFBasicHash.h b/CFBasicHash.h new file mode 120000 index 0000000..eb694db --- /dev/null +++ b/CFBasicHash.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBasicHash.h \ No newline at end of file diff --git a/CFBigNumber.h b/CFBigNumber.h deleted file mode 100644 index 574ad3a..0000000 --- a/CFBigNumber.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBigNumber.h - Copyright (c) 2012-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFBIGNUMBER__) -#define __COREFOUNDATION_CFBIGNUMBER__ 1 - -#include -#include - - -// Base 1 billion number: each digit represents 0 to 999999999 -typedef struct { - uint32_t digits[5]; - int32_t sign:8; - uint32_t __:24; -} _CFBigNum; - -void _CFBigNumInitWithInt8(_CFBigNum *r, int8_t inNum); -void _CFBigNumInitWithInt16(_CFBigNum *r, int16_t inNum); -void _CFBigNumInitWithInt32(_CFBigNum *r, int32_t inNum); -void _CFBigNumInitWithInt64(_CFBigNum *r, int64_t inNum); -#ifdef __LP64__ -void _CFBigNumInitWithInt128(_CFBigNum *r, __int128_t inNum); -#endif - -void _CFBigNumInitWithUInt8(_CFBigNum *r, uint8_t inNum); -void _CFBigNumInitWithUInt16(_CFBigNum *r, uint16_t inNum); -void _CFBigNumInitWithUInt32(_CFBigNum *r, uint32_t inNum); -void _CFBigNumInitWithUInt64(_CFBigNum *r, uint64_t inNum); -#ifdef __LP64__ -void _CFBigNumInitWithUInt128(_CFBigNum *r, __uint128_t inNum); -#endif - -int8_t _CFBigNumGetInt8(const _CFBigNum *num); -int16_t _CFBigNumGetInt16(const _CFBigNum *num); -int32_t _CFBigNumGetInt32(const _CFBigNum *num); -int64_t _CFBigNumGetInt64(const _CFBigNum *num); -#ifdef __LP64__ -__int128_t _CFBigNumGetInt128(const _CFBigNum *num); -#endif - -uint8_t _CFBigNumGetUInt8(const _CFBigNum *num); -uint16_t _CFBigNumGetUInt16(const _CFBigNum *num); -uint32_t _CFBigNumGetUInt32(const _CFBigNum *num); -uint64_t _CFBigNumGetUInt64(const _CFBigNum *num); -#ifdef __LP64__ -__uint128_t _CFBigNumGetUInt128(const _CFBigNum *num); -#endif - -void _CFBigNumInitWithCFNumber(_CFBigNum *r, CFNumberRef input); -void _CFBigNumInitWithBytes(_CFBigNum *r, const void *bytes, CFNumberType type); -CFNumberRef _CFNumberCreateWithBigNum(const _CFBigNum *input); - - -CFComparisonResult _CFBigNumCompare(const _CFBigNum *a, const _CFBigNum *b); - -void _CFBigNumNeg(_CFBigNum *r, const _CFBigNum *a); -uint8_t _CFBigNumAdd(_CFBigNum *r, const _CFBigNum *a, const _CFBigNum *b); -uint8_t _CFBigNumSub(_CFBigNum *r, const _CFBigNum *a, const _CFBigNum *b); - - -void _CFBigNumToCString(const _CFBigNum *vp, Boolean leading_zeros, Boolean leading_plus, char *buffer, size_t buflen); -void _CFBigNumFromCString(_CFBigNum *r, const char *string); - -char *_CFBigNumCopyDescription(const _CFBigNum *num); // caller must free() returned ptr - - -#endif /* ! __COREFOUNDATION_CFBIGNUMBER__ */ - diff --git a/CFBigNumber.h b/CFBigNumber.h new file mode 120000 index 0000000..e62a964 --- /dev/null +++ b/CFBigNumber.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBigNumber.h \ No newline at end of file diff --git a/CFBinaryHeap.h b/CFBinaryHeap.h deleted file mode 100644 index 5724f66..0000000 --- a/CFBinaryHeap.h +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBinaryHeap.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ -/*! - @header CFBinaryHeap - CFBinaryHeap implements a container which stores values sorted using - a binary search algorithm. CFBinaryHeaps can be useful as priority - queues. -*/ - -#if !defined(__COREFOUNDATION_CFBINARYHEAP__) -#define __COREFOUNDATION_CFBINARYHEAP__ 1 - -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct { - CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); -} CFBinaryHeapCompareContext; - -/*! - @typedef CFBinaryHeapCallBacks - Structure containing the callbacks for values of a CFBinaryHeap. - @field version The version number of the structure type being passed - in as a parameter to the CFBinaryHeap creation functions. - This structure is version 0. - @field retain The callback used to add a retain for the binary heap - on values as they are put into the binary heap. - This callback returns the value to use as the value in the - binary heap, which is usually the value parameter passed to - this callback, but may be a different value if a different - value should be added to the binary heap. The binary heap's - allocator is passed as the first argument. - @field release The callback used to remove a retain previously added - for the binary heap from values as they are removed from - the binary heap. The binary heap's allocator is passed as the - first argument. - @field copyDescription The callback used to create a descriptive - string representation of each value in the binary heap. This - is used by the CFCopyDescription() function. - @field compare The callback used to compare values in the binary heap for - equality in some operations. -*/ -typedef struct { - CFIndex version; - const void *(*retain)(CFAllocatorRef allocator, const void *ptr); - void (*release)(CFAllocatorRef allocator, const void *ptr); - CFStringRef (*copyDescription)(const void *ptr); - CFComparisonResult (*compare)(const void *ptr1, const void *ptr2, void *context); -} CFBinaryHeapCallBacks; - -/*! - @constant kCFStringBinaryHeapCallBacks - Predefined CFBinaryHeapCallBacks structure containing a set - of callbacks appropriate for use when the values in a CFBinaryHeap - are all CFString types. -*/ -CF_EXPORT const CFBinaryHeapCallBacks kCFStringBinaryHeapCallBacks; - -/*! - @typedef CFBinaryHeapApplierFunction - Type of the callback function used by the apply functions of - CFBinaryHeap. - @param value The current value from the binary heap. - @param context The user-defined context parameter given to the apply - function. -*/ -typedef void (*CFBinaryHeapApplierFunction)(const void *val, void *context); - -/*! - @typedef CFBinaryHeapRef - This is the type of a reference to CFBinaryHeaps. -*/ -typedef struct __CFBinaryHeap * CFBinaryHeapRef; - -/*! - @function CFBinaryHeapGetTypeID - Returns the type identifier of all CFBinaryHeap instances. -*/ -CF_EXPORT CFTypeID CFBinaryHeapGetTypeID(void); - -/*! - @function CFBinaryHeapCreate - Creates a new mutable binary heap with the given values. - @param allocator The CFAllocator which should be used to allocate - memory for the binary heap and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param capacity A hint about the number of values that will be held - by the CFBinaryHeap. Pass 0 for no hint. The implementation may - ignore this hint, or may use it to optimize various - operations. A heap's actual capacity is only limited by - address space and available memory constraints). If this - parameter is negative, the behavior is undefined. - @param callBacks A pointer to a CFBinaryHeapCallBacks structure - initialized with the callbacks for the binary heap to use on - each value in the binary heap. A copy of the contents of the - callbacks structure is made, so that a pointer to a structure - on the stack can be passed in, or can be reused for multiple - binary heap creations. If the version field of this callbacks - structure is not one of the defined ones for CFBinaryHeap, the - behavior is undefined. The retain field may be NULL, in which - case the CFBinaryHeap will do nothing to add a retain to values - as they are put into the binary heap. The release field may be - NULL, in which case the CFBinaryHeap will do nothing to remove - the binary heap's retain (if any) on the values when the - heap is destroyed or a key-value pair is removed. If the - copyDescription field is NULL, the binary heap will create a - simple description for a value. If the equal field is NULL, the - binary heap will use pointer equality to test for equality of - values. This callbacks parameter itself may be NULL, which is - treated as if a valid structure of version 0 with all fields - NULL had been passed in. Otherwise, - if any of the fields are not valid pointers to functions - of the correct type, or this parameter is not a valid - pointer to a CFBinaryHeapCallBacks callbacks structure, - the behavior is undefined. If any of the values put into the - binary heap is not one understood by one of the callback functions - the behavior when that callback function is used is undefined. - @param compareContext A pointer to a CFBinaryHeapCompareContext structure. - @result A reference to the new CFBinaryHeap. -*/ -CF_EXPORT CFBinaryHeapRef CFBinaryHeapCreate(CFAllocatorRef allocator, CFIndex capacity, const CFBinaryHeapCallBacks *callBacks, const CFBinaryHeapCompareContext *compareContext); - -/*! - @function CFBinaryHeapCreateCopy - Creates a new mutable binary heap with the values from the given binary heap. - @param allocator The CFAllocator which should be used to allocate - memory for the binary heap and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param capacity A hint about the number of values that will be held - by the CFBinaryHeap. Pass 0 for no hint. The implementation may - ignore this hint, or may use it to optimize various - operations. A heap's actual capacity is only limited by - address space and available memory constraints). - This parameter must be greater than or equal - to the count of the heap which is to be copied, or the - behavior is undefined. If this parameter is negative, the - behavior is undefined. - @param heap The binary heap which is to be copied. The values from the - binary heap are copied as pointers into the new binary heap (that is, - the values themselves are copied, not that which the values - point to, if anything). However, the values are also - retained by the new binary heap. The count of the new binary will - be the same as the given binary heap. The new binary heap uses the same - callbacks as the binary heap to be copied. If this parameter is - not a valid CFBinaryHeap, the behavior is undefined. - @result A reference to the new mutable binary heap. -*/ -CF_EXPORT CFBinaryHeapRef CFBinaryHeapCreateCopy(CFAllocatorRef allocator, CFIndex capacity, CFBinaryHeapRef heap); - -/*! - @function CFBinaryHeapGetCount - Returns the number of values currently in the binary heap. - @param heap The binary heap to be queried. If this parameter is not a valid - CFBinaryHeap, the behavior is undefined. - @result The number of values in the binary heap. -*/ -CF_EXPORT CFIndex CFBinaryHeapGetCount(CFBinaryHeapRef heap); - -/*! - @function CFBinaryHeapGetCountOfValue - Counts the number of times the given value occurs in the binary heap. - @param heap The binary heap to be searched. If this parameter is not a - valid CFBinaryHeap, the behavior is undefined. - @param value The value for which to find matches in the binary heap. The - compare() callback provided when the binary heap was created is - used to compare. If the compare() callback was NULL, pointer - equality (in C, ==) is used. If value, or any of the values - in the binary heap, are not understood by the compare() callback, - the behavior is undefined. - @result The number of times the given value occurs in the binary heap. -*/ -CF_EXPORT CFIndex CFBinaryHeapGetCountOfValue(CFBinaryHeapRef heap, const void *value); - -/*! - @function CFBinaryHeapContainsValue - Reports whether or not the value is in the binary heap. - @param heap The binary heap to be searched. If this parameter is not a - valid CFBinaryHeap, the behavior is undefined. - @param value The value for which to find matches in the binary heap. The - compare() callback provided when the binary heap was created is - used to compare. If the compare() callback was NULL, pointer - equality (in C, ==) is used. If value, or any of the values - in the binary heap, are not understood by the compare() callback, - the behavior is undefined. - @result true, if the value is in the specified binary heap, otherwise false. -*/ -CF_EXPORT Boolean CFBinaryHeapContainsValue(CFBinaryHeapRef heap, const void *value); - -/*! - @function CFBinaryHeapGetMinimum - Returns the minimum value is in the binary heap. If the heap contains several equal - minimum values, any one may be returned. - @param heap The binary heap to be searched. If this parameter is not a - valid CFBinaryHeap, the behavior is undefined. - @result A reference to the minimum value in the binary heap, or NULL if the - binary heap contains no values. -*/ -CF_EXPORT const void * CFBinaryHeapGetMinimum(CFBinaryHeapRef heap); - -/*! - @function CFBinaryHeapGetMinimumIfPresent - Returns the minimum value is in the binary heap, if present. If the heap contains several equal - minimum values, any one may be returned. - @param heap The binary heap to be searched. If this parameter is not a - valid CFBinaryHeap, the behavior is undefined. - @param value A C pointer to pointer-sized storage to be filled with the minimum value in - the binary heap. If this value is not a valid C pointer to a pointer-sized block - of storage, the result is undefined. If the result of the function is false, the value - stored at this address is undefined. - @result true, if a minimum value was found in the specified binary heap, otherwise false. -*/ -CF_EXPORT Boolean CFBinaryHeapGetMinimumIfPresent(CFBinaryHeapRef heap, const void **value); - -/*! - @function CFBinaryHeapGetValues - Fills the buffer with values from the binary heap. - @param heap The binary heap to be queried. If this parameter is not a - valid CFBinaryHeap, the behavior is undefined. - @param values A C array of pointer-sized values to be filled with - values from the binary heap. The values in the C array are ordered - from least to greatest. If this parameter is not a valid pointer to a - C array of at least CFBinaryHeapGetCount() pointers, the behavior is undefined. -*/ -CF_EXPORT void CFBinaryHeapGetValues(CFBinaryHeapRef heap, const void **values); - -/*! - @function CFBinaryHeapApplyFunction - Calls a function once for each value in the binary heap. - @param heap The binary heap to be operated upon. If this parameter is not a - valid CFBinaryHeap, the behavior is undefined. - @param applier The callback function to call once for each value in - the given binary heap. If this parameter is not a - pointer to a function of the correct prototype, the behavior - is undefined. If there are values in the binary heap which the - applier function does not expect or cannot properly apply - to, the behavior is undefined. - @param context A pointer-sized user-defined value, which is passed - as the second parameter to the applier function, but is - otherwise unused by this function. If the context is not - what is expected by the applier function, the behavior is - undefined. -*/ -CF_EXPORT void CFBinaryHeapApplyFunction(CFBinaryHeapRef heap, CFBinaryHeapApplierFunction applier, void *context); - -/*! - @function CFBinaryHeapAddValue - Adds the value to the binary heap. - @param heap The binary heap to which the value is to be added. If this parameter is not a - valid mutable CFBinaryHeap, the behavior is undefined. - @param value The value to add to the binary heap. The value is retained by - the binary heap using the retain callback provided when the binary heap - was created. If the value is not of the sort expected by the - retain callback, the behavior is undefined. -*/ -CF_EXPORT void CFBinaryHeapAddValue(CFBinaryHeapRef heap, const void *value); - -/*! - @function CFBinaryHeapRemoveMinimumValue - Removes the minimum value from the binary heap. - @param heap The binary heap from which the minimum value is to be removed. If this - parameter is not a valid mutable CFBinaryHeap, the behavior is undefined. -*/ -CF_EXPORT void CFBinaryHeapRemoveMinimumValue(CFBinaryHeapRef heap); - -/*! - @function CFBinaryHeapRemoveAllValues - Removes all the values from the binary heap, making it empty. - @param heap The binary heap from which all of the values are to be - removed. If this parameter is not a valid mutable CFBinaryHeap, - the behavior is undefined. -*/ -CF_EXPORT void CFBinaryHeapRemoveAllValues(CFBinaryHeapRef heap); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFBINARYHEAP__ */ - diff --git a/CFBinaryHeap.h b/CFBinaryHeap.h new file mode 120000 index 0000000..4858c50 --- /dev/null +++ b/CFBinaryHeap.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBinaryHeap.h \ No newline at end of file diff --git a/CFBitVector.h b/CFBitVector.h deleted file mode 100644 index 84ba382..0000000 --- a/CFBitVector.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBitVector.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFBITVECTOR__) -#define __COREFOUNDATION_CFBITVECTOR__ 1 - -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef UInt32 CFBit; - -typedef const struct __CFBitVector * CFBitVectorRef; -typedef struct __CFBitVector * CFMutableBitVectorRef; - -CF_EXPORT CFTypeID CFBitVectorGetTypeID(void); - -CF_EXPORT CFBitVectorRef CFBitVectorCreate(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex numBits); -CF_EXPORT CFBitVectorRef CFBitVectorCreateCopy(CFAllocatorRef allocator, CFBitVectorRef bv); -CF_EXPORT CFMutableBitVectorRef CFBitVectorCreateMutable(CFAllocatorRef allocator, CFIndex capacity); -CF_EXPORT CFMutableBitVectorRef CFBitVectorCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFBitVectorRef bv); - -CF_EXPORT CFIndex CFBitVectorGetCount(CFBitVectorRef bv); -CF_EXPORT CFIndex CFBitVectorGetCountOfBit(CFBitVectorRef bv, CFRange range, CFBit value); -CF_EXPORT Boolean CFBitVectorContainsBit(CFBitVectorRef bv, CFRange range, CFBit value); -CF_EXPORT CFBit CFBitVectorGetBitAtIndex(CFBitVectorRef bv, CFIndex idx); -CF_EXPORT void CFBitVectorGetBits(CFBitVectorRef bv, CFRange range, UInt8 *bytes); -CF_EXPORT CFIndex CFBitVectorGetFirstIndexOfBit(CFBitVectorRef bv, CFRange range, CFBit value); -CF_EXPORT CFIndex CFBitVectorGetLastIndexOfBit(CFBitVectorRef bv, CFRange range, CFBit value); - -CF_EXPORT void CFBitVectorSetCount(CFMutableBitVectorRef bv, CFIndex count); -CF_EXPORT void CFBitVectorFlipBitAtIndex(CFMutableBitVectorRef bv, CFIndex idx); -CF_EXPORT void CFBitVectorFlipBits(CFMutableBitVectorRef bv, CFRange range); -CF_EXPORT void CFBitVectorSetBitAtIndex(CFMutableBitVectorRef bv, CFIndex idx, CFBit value); -CF_EXPORT void CFBitVectorSetBits(CFMutableBitVectorRef bv, CFRange range, CFBit value); -CF_EXPORT void CFBitVectorSetAllBits(CFMutableBitVectorRef bv, CFBit value); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFBITVECTOR__ */ - diff --git a/CFBitVector.h b/CFBitVector.h new file mode 120000 index 0000000..c7cac73 --- /dev/null +++ b/CFBitVector.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBitVector.h \ No newline at end of file diff --git a/CFBundle.h b/CFBundle.h deleted file mode 100644 index 4727f60..0000000 --- a/CFBundle.h +++ /dev/null @@ -1,358 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBundle.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFBUNDLE__) -#define __COREFOUNDATION_CFBUNDLE__ 1 - -#include -#include -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct __CFBundle *CFBundleRef; -typedef struct __CFBundle *CFPlugInRef; - -/* ===================== Standard Info.plist keys ===================== */ -CF_EXPORT -const CFStringRef kCFBundleInfoDictionaryVersionKey; - /* The version of the Info.plist format */ -CF_EXPORT -const CFStringRef kCFBundleExecutableKey; - /* The name of the executable in this bundle, if any */ -CF_EXPORT -const CFStringRef kCFBundleIdentifierKey; - /* The bundle identifier (for CFBundleGetBundleWithIdentifier()) */ -CF_EXPORT -const CFStringRef kCFBundleVersionKey; - /* The version number of the bundle. For Mac OS 9 style version numbers (for example "2.5.3d5"), */ - /* clients can use CFBundleGetVersionNumber() instead of accessing this key directly since that */ - /* function will properly convert the version string into its compact integer representation. */ -CF_EXPORT -const CFStringRef kCFBundleDevelopmentRegionKey; - /* The name of the development language of the bundle. */ -CF_EXPORT -const CFStringRef kCFBundleNameKey; - /* The human-readable name of the bundle. This key is often found in the InfoPlist.strings since it is usually localized. */ -CF_EXPORT -const CFStringRef kCFBundleLocalizationsKey; - /* Allows an unbundled application that handles localization itself to specify which localizations it has available. */ - -/* ===================== Finding Bundles ===================== */ - -CF_EXPORT -CFBundleRef CFBundleGetMainBundle(void); - -CF_EXPORT -CFBundleRef CFBundleGetBundleWithIdentifier(CFStringRef bundleID); - /* A bundle can name itself by providing a key in the info dictionary. */ - /* This facility is meant to allow bundle-writers to get hold of their */ - /* bundle from their code without having to know where it was on the disk. */ - /* This is meant to be a replacement mechanism for +bundleForClass: users. */ - /* Note that this does not search for bundles on the disk; it will locate */ - /* only bundles already loaded or otherwise known to the current process. */ - -CF_EXPORT -CFArrayRef CFBundleGetAllBundles(void); - /* This is potentially expensive, and not thread-safe. Use with care. */ - /* Best used for debuggging or other diagnostic purposes. */ - -/* ===================== Creating Bundles ===================== */ - -CF_EXPORT -CFTypeID CFBundleGetTypeID(void); - -CF_EXPORT -CFBundleRef CFBundleCreate(CFAllocatorRef allocator, CFURLRef bundleURL); - /* Might return an existing instance with the ref-count bumped. */ - -CF_EXPORT -CFArrayRef CFBundleCreateBundlesFromDirectory(CFAllocatorRef allocator, CFURLRef directoryURL, CFStringRef bundleType); - /* Create instances for all bundles in the given directory matching the given type */ - /* (or all of them if bundleType is NULL). Instances are created using CFBundleCreate() and are not released. */ - -/* ==================== Basic Bundle Info ==================== */ - -CF_EXPORT -CFURLRef CFBundleCopyBundleURL(CFBundleRef bundle); - -CF_EXPORT -CFTypeRef CFBundleGetValueForInfoDictionaryKey(CFBundleRef bundle, CFStringRef key); - /* Returns a localized value if available, otherwise the global value. */ - /* This is the recommended function for examining the info dictionary. */ - -CF_EXPORT -CFDictionaryRef CFBundleGetInfoDictionary(CFBundleRef bundle); - /* This is the global info dictionary. Note that CFBundle may add */ - /* extra keys to the dictionary for its own use. */ - -CF_EXPORT -CFDictionaryRef CFBundleGetLocalInfoDictionary(CFBundleRef bundle); - /* This is the localized info dictionary. */ - -CF_EXPORT -void CFBundleGetPackageInfo(CFBundleRef bundle, UInt32 *packageType, UInt32 *packageCreator); - -CF_EXPORT -CFStringRef CFBundleGetIdentifier(CFBundleRef bundle); - -CF_EXPORT -UInt32 CFBundleGetVersionNumber(CFBundleRef bundle); - -CF_EXPORT -CFStringRef CFBundleGetDevelopmentRegion(CFBundleRef bundle); - -CF_EXPORT -CFURLRef CFBundleCopySupportFilesDirectoryURL(CFBundleRef bundle); - -CF_EXPORT -CFURLRef CFBundleCopyResourcesDirectoryURL(CFBundleRef bundle); - -CF_EXPORT -CFURLRef CFBundleCopyPrivateFrameworksURL(CFBundleRef bundle); - -CF_EXPORT -CFURLRef CFBundleCopySharedFrameworksURL(CFBundleRef bundle); - -CF_EXPORT -CFURLRef CFBundleCopySharedSupportURL(CFBundleRef bundle); - -CF_EXPORT -CFURLRef CFBundleCopyBuiltInPlugInsURL(CFBundleRef bundle); - -/* ------------- Basic Bundle Info without a CFBundle instance ------------- */ -/* This API is provided to enable developers to retrieve basic information */ -/* about a bundle without having to create an instance of CFBundle. */ -/* Because of caching behavior when a CFBundle instance exists, it will be faster */ -/* to actually create a CFBundle if you need to retrieve multiple pieces of info. */ -CF_EXPORT -CFDictionaryRef CFBundleCopyInfoDictionaryInDirectory(CFURLRef bundleURL); - -CF_EXPORT -Boolean CFBundleGetPackageInfoInDirectory(CFURLRef url, UInt32 *packageType, UInt32 *packageCreator); - -/* ==================== Resource Handling API ==================== */ - -CF_EXPORT -CFURLRef CFBundleCopyResourceURL(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName); - -CF_EXPORT -CFArrayRef CFBundleCopyResourceURLsOfType(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName); - -CF_EXPORT -CFStringRef CFBundleCopyLocalizedString(CFBundleRef bundle, CFStringRef key, CFStringRef value, CFStringRef tableName) CF_FORMAT_ARGUMENT(2); - -#define CFCopyLocalizedString(key, comment) \ - CFBundleCopyLocalizedString(CFBundleGetMainBundle(), (key), (key), NULL) -#define CFCopyLocalizedStringFromTable(key, tbl, comment) \ - CFBundleCopyLocalizedString(CFBundleGetMainBundle(), (key), (key), (tbl)) -#define CFCopyLocalizedStringFromTableInBundle(key, tbl, bundle, comment) \ - CFBundleCopyLocalizedString((bundle), (key), (key), (tbl)) -#define CFCopyLocalizedStringWithDefaultValue(key, tbl, bundle, value, comment) \ - CFBundleCopyLocalizedString((bundle), (key), (value), (tbl)) - -/* ------------- Resource Handling without a CFBundle instance ------------- */ -/* This API is provided to enable developers to use the CFBundle resource */ -/* searching policy without having to create an instance of CFBundle. */ -/* Because of caching behavior when a CFBundle instance exists, it will be faster */ -/* to actually create a CFBundle if you need to access several resources. */ - -CF_EXPORT -CFURLRef CFBundleCopyResourceURLInDirectory(CFURLRef bundleURL, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName); - -CF_EXPORT -CFArrayRef CFBundleCopyResourceURLsOfTypeInDirectory(CFURLRef bundleURL, CFStringRef resourceType, CFStringRef subDirName); - -/* =========== Localization-specific Resource Handling API =========== */ -/* This API allows finer-grained control over specific localizations, */ -/* as distinguished from the above API, which always uses the user's */ -/* preferred localizations for the bundle in the current app context. */ - -CF_EXPORT -CFArrayRef CFBundleCopyBundleLocalizations(CFBundleRef bundle); - /* Lists the localizations that a bundle contains. */ - -CF_EXPORT -CFArrayRef CFBundleCopyPreferredLocalizationsFromArray(CFArrayRef locArray); - /* Given an array of possible localizations, returns the one or more */ - /* of them that CFBundle would use in the current application context. */ - /* To determine the localizations that would be used for a particular */ - /* bundle in the current application context, apply this function to the */ - /* result of CFBundleCopyBundleLocalizations(). */ - -CF_EXPORT -CFArrayRef CFBundleCopyLocalizationsForPreferences(CFArrayRef locArray, CFArrayRef prefArray); - /* Given an array of possible localizations, returns the one or more of */ - /* them that CFBundle would use, without reference to the current application */ - /* context, if the user's preferred localizations were given by prefArray. */ - /* If prefArray is NULL, the current user's actual preferred localizations will */ - /* be used. This is not the same as CFBundleCopyPreferredLocalizationsFromArray(), */ - /* because that function takes the current application context into account. */ - /* To determine the localizations that another application would use, apply */ - /* this function to the result of CFBundleCopyBundleLocalizations(). */ - -CF_EXPORT -CFURLRef CFBundleCopyResourceURLForLocalization(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName, CFStringRef localizationName); - -CF_EXPORT -CFArrayRef CFBundleCopyResourceURLsOfTypeForLocalization(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName, CFStringRef localizationName); - /* The localizationName argument to CFBundleCopyResourceURLForLocalization() or */ - /* CFBundleCopyResourceURLsOfTypeForLocalization() must be identical to one of the */ - /* localizations in the bundle, as returned by CFBundleCopyBundleLocalizations(). */ - /* It is recommended that either CFBundleCopyPreferredLocalizationsFromArray() or */ - /* CFBundleCopyLocalizationsForPreferences() be used to select the localization. */ - -/* =================== Unbundled application info ===================== */ -/* This API is provided to enable developers to retrieve bundle-related */ -/* information about an application that may be bundled or unbundled. */ -CF_EXPORT -CFDictionaryRef CFBundleCopyInfoDictionaryForURL(CFURLRef url); - /* For a directory URL, this is equivalent to CFBundleCopyInfoDictionaryInDirectory(). */ - /* For a plain file URL representing an unbundled executable, this will attempt to read */ - /* an info dictionary from the (__TEXT, __info_plist) section, if it is a Mach-o file, */ - /* or from a 'plst' resource. */ - -CF_EXPORT -CFArrayRef CFBundleCopyLocalizationsForURL(CFURLRef url); - /* For a directory URL, this is equivalent to calling CFBundleCopyBundleLocalizations() */ - /* on the corresponding bundle. For a plain file URL representing an unbundled executable, */ - /* this will attempt to determine its localizations using the CFBundleLocalizations and */ - /* CFBundleDevelopmentRegion keys in the dictionary returned by CFBundleCopyInfoDictionaryForURL,*/ - /* or from a 'vers' resource if those are not present. */ - -CF_EXPORT -CFArrayRef CFBundleCopyExecutableArchitecturesForURL(CFURLRef url) CF_AVAILABLE(10_5, 2_0); - /* For a directory URL, this is equivalent to calling CFBundleCopyExecutableArchitectures() */ - /* on the corresponding bundle. For a plain file URL representing an unbundled executable, */ - /* this will return the architectures it provides, if it is a Mach-o file, or NULL otherwise. */ - -/* ==================== Primitive Code Loading API ==================== */ -/* This API abstracts the various different executable formats supported on */ -/* various platforms. It can load DYLD, CFM, or DLL shared libraries (on their */ -/* appropriate platforms) and gives a uniform API for looking up functions. */ - -CF_EXPORT -CFURLRef CFBundleCopyExecutableURL(CFBundleRef bundle); - -enum { - kCFBundleExecutableArchitectureI386 = 0x00000007, - kCFBundleExecutableArchitecturePPC = 0x00000012, - kCFBundleExecutableArchitectureX86_64 = 0x01000007, - kCFBundleExecutableArchitecturePPC64 = 0x01000012 -} CF_ENUM_AVAILABLE(10_5, 2_0); - -CF_EXPORT -CFArrayRef CFBundleCopyExecutableArchitectures(CFBundleRef bundle) CF_AVAILABLE(10_5, 2_0); - /* If the bundle's executable exists and is a Mach-o file, this function will return an array */ - /* of CFNumbers whose values are integers representing the architectures the file provides. */ - /* The values currently in use are those listed in the enum above, but others may be added */ - /* in the future. If the executable is not a Mach-o file, this function returns NULL. */ - -CF_EXPORT -Boolean CFBundlePreflightExecutable(CFBundleRef bundle, CFErrorRef *error) CF_AVAILABLE(10_5, 2_0); - /* This function will return true if the bundle is loaded, or if the bundle appears to be */ - /* loadable upon inspection. This does not mean that the bundle is definitively loadable, */ - /* since it may fail to load due to link errors or other problems not readily detectable. */ - /* If this function detects problems, it will return false, and return a CFError by reference. */ - /* It is the responsibility of the caller to release the CFError. */ - -CF_EXPORT -Boolean CFBundleLoadExecutableAndReturnError(CFBundleRef bundle, CFErrorRef *error) CF_AVAILABLE(10_5, 2_0); - /* If the bundle is already loaded, this function will return true. Otherwise, it will attempt */ - /* to load the bundle, and it will return true if that attempt succeeds. If the bundle fails */ - /* to load, this function will return false, and it will return a CFError by reference. */ - /* It is the responsibility of the caller to release the CFError. */ - -CF_EXPORT -Boolean CFBundleLoadExecutable(CFBundleRef bundle); - -CF_EXPORT -Boolean CFBundleIsExecutableLoaded(CFBundleRef bundle); - -CF_EXPORT -void CFBundleUnloadExecutable(CFBundleRef bundle); - -CF_EXPORT -void *CFBundleGetFunctionPointerForName(CFBundleRef bundle, CFStringRef functionName); - -CF_EXPORT -void CFBundleGetFunctionPointersForNames(CFBundleRef bundle, CFArrayRef functionNames, void *ftbl[]); - -CF_EXPORT -void *CFBundleGetDataPointerForName(CFBundleRef bundle, CFStringRef symbolName); - -CF_EXPORT -void CFBundleGetDataPointersForNames(CFBundleRef bundle, CFArrayRef symbolNames, void *stbl[]); - -CF_EXPORT -CFURLRef CFBundleCopyAuxiliaryExecutableURL(CFBundleRef bundle, CFStringRef executableName); - /* This function can be used to find executables other than your main */ - /* executable. This is useful, for instance, for applications that have */ - /* some command line tool that is packaged with and used by the application. */ - /* The tool can be packaged in the various platform executable directories */ - /* in the bundle and can be located with this function. This allows an */ - /* app to ship versions of the tool for each platform as it does for the */ - /* main app executable. */ - -/* ==================== Getting a bundle's plugIn ==================== */ - -CF_EXPORT -CFPlugInRef CFBundleGetPlugIn(CFBundleRef bundle); - -/* ==================== Resource Manager-Related API ==================== */ - -#if __LP64__ -typedef int CFBundleRefNum; -#else -typedef SInt16 CFBundleRefNum; -#endif - -CF_EXPORT -CFBundleRefNum CFBundleOpenBundleResourceMap(CFBundleRef bundle); - /* This function opens the non-localized and the localized resource files */ - /* (if any) for the bundle, creates and makes current a single read-only */ - /* resource map combining both, and returns a reference number for it. */ - /* If it is called multiple times, it opens the files multiple times, */ - /* and returns distinct reference numbers. */ - -CF_EXPORT -SInt32 CFBundleOpenBundleResourceFiles(CFBundleRef bundle, CFBundleRefNum *refNum, CFBundleRefNum *localizedRefNum); - /* Similar to CFBundleOpenBundleResourceMap(), except that it creates two */ - /* separate resource maps and returns reference numbers for both. */ - -CF_EXPORT -void CFBundleCloseBundleResourceMap(CFBundleRef bundle, CFBundleRefNum refNum); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFBUNDLE__ */ - diff --git a/CFBundle.h b/CFBundle.h new file mode 120000 index 0000000..57a3783 --- /dev/null +++ b/CFBundle.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBundle.h \ No newline at end of file diff --git a/CFBundlePriv.h b/CFBundlePriv.h deleted file mode 100644 index d4feb5f..0000000 --- a/CFBundlePriv.h +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBundlePriv.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFBUNDLEPRIV__) -#define __COREFOUNDATION_CFBUNDLEPRIV__ 1 - -#include -#include -#include -#include -#include -#include - -CF_EXTERN_C_BEGIN - -/* Finder stuff */ -CF_EXPORT -const CFStringRef _kCFBundlePackageTypeKey; -CF_EXPORT -const CFStringRef _kCFBundleSignatureKey; -CF_EXPORT -const CFStringRef _kCFBundleIconFileKey; -CF_EXPORT -const CFStringRef _kCFBundleDocumentTypesKey; -CF_EXPORT -const CFStringRef _kCFBundleURLTypesKey; - -/* Localizable Finder stuff */ -CF_EXPORT -const CFStringRef _kCFBundleDisplayNameKey; -CF_EXPORT -const CFStringRef _kCFBundleShortVersionStringKey; -CF_EXPORT -const CFStringRef _kCFBundleGetInfoStringKey; -CF_EXPORT -const CFStringRef _kCFBundleGetInfoHTMLKey; - -/* Sub-keys for CFBundleDocumentTypes dictionaries */ -CF_EXPORT -const CFStringRef _kCFBundleTypeNameKey; -CF_EXPORT -const CFStringRef _kCFBundleTypeRoleKey; -CF_EXPORT -const CFStringRef _kCFBundleTypeIconFileKey; -CF_EXPORT -const CFStringRef _kCFBundleTypeOSTypesKey; -CF_EXPORT -const CFStringRef _kCFBundleTypeExtensionsKey; -CF_EXPORT -const CFStringRef _kCFBundleTypeMIMETypesKey; - -/* Sub-keys for CFBundleURLTypes dictionaries */ -CF_EXPORT -const CFStringRef _kCFBundleURLNameKey; -CF_EXPORT -const CFStringRef _kCFBundleURLIconFileKey; -CF_EXPORT -const CFStringRef _kCFBundleURLSchemesKey; - -/* Compatibility key names */ -CF_EXPORT -const CFStringRef _kCFBundleOldExecutableKey; -CF_EXPORT -const CFStringRef _kCFBundleOldInfoDictionaryVersionKey; -CF_EXPORT -const CFStringRef _kCFBundleOldNameKey; -CF_EXPORT -const CFStringRef _kCFBundleOldIconFileKey; -CF_EXPORT -const CFStringRef _kCFBundleOldDocumentTypesKey; -CF_EXPORT -const CFStringRef _kCFBundleOldShortVersionStringKey; - -/* Compatibility CFBundleDocumentTypes key names */ -CF_EXPORT -const CFStringRef _kCFBundleOldTypeNameKey; -CF_EXPORT -const CFStringRef _kCFBundleOldTypeRoleKey; -CF_EXPORT -const CFStringRef _kCFBundleOldTypeIconFileKey; -CF_EXPORT -const CFStringRef _kCFBundleOldTypeExtensions1Key; -CF_EXPORT -const CFStringRef _kCFBundleOldTypeExtensions2Key; -CF_EXPORT -const CFStringRef _kCFBundleOldTypeOSTypesKey; - -/* For platform specification */ -CF_EXPORT -const CFStringRef _kCFBundleSupportedPlatformsKey; - -/* For Code Signing */ -CF_EXPORT -const CFStringRef _kCFBundleResourceSpecificationKey; - - -/* Functions for examining directories that may "look like" bundles */ - -CF_EXPORT -CFURLRef _CFBundleCopyBundleURLForExecutableURL(CFURLRef url); - -CF_EXPORT -Boolean _CFBundleURLLooksLikeBundle(CFURLRef url); - -CF_EXPORT -CFBundleRef _CFBundleCreateIfLooksLikeBundle(CFAllocatorRef allocator, CFURLRef url); - -CF_EXPORT -CFBundleRef _CFBundleGetMainBundleIfLooksLikeBundle(void); - -CF_EXPORT -Boolean _CFBundleMainBundleInfoDictionaryComesFromResourceFork(void); - -CF_EXPORT -CFBundleRef _CFBundleCreateWithExecutableURLIfLooksLikeBundle(CFAllocatorRef allocator, CFURLRef url); - -CF_EXPORT -CFURLRef _CFBundleCopyMainBundleExecutableURL(Boolean *looksLikeBundle); - -CF_EXPORT -CFBundleRef _CFBundleGetExistingBundleWithBundleURL(CFURLRef bundleURL); - -// This function is obsolete. -CF_EXPORT -CFArrayRef _CFBundleGetSupportedPlatforms(CFBundleRef bundle); - -CF_EXPORT -CFStringRef _CFBundleGetCurrentPlatform(void); - - -/* For Code Signing */ - -// This function is obsolete. Use CFBundleCreate instead. -CF_EXPORT -CFBundleRef _CFBundleCreateIfMightBeBundle(CFAllocatorRef allocator, CFURLRef url) CF_DEPRECATED(10_6, 10_10, 2_0, 8_0); - -// This function is for code signing only. Do not use this function. -CF_EXPORT -CFBundleRef _CFBundleCreateWithExecutableURLIfMightBeBundle(CFAllocatorRef allocator, CFURLRef url); - - -/* Functions for examining the structure of a bundle */ - -CF_EXPORT -CFURLRef _CFBundleCopyResourceForkURL(CFBundleRef bundle) CF_AVAILABLE_MAC(10_0); - -CF_EXPORT -CFURLRef _CFBundleCopyInfoPlistURL(CFBundleRef bundle); - - -/* Functions for working without a bundle instance */ - -CF_EXPORT -CFURLRef _CFBundleCopyExecutableURLInDirectory(CFURLRef url); - -CF_EXPORT -CFURLRef _CFBundleCopyOtherExecutableURLInDirectory(CFURLRef url); - - -/* Functions for dealing with localizations */ - -CF_EXPORT -void _CFBundleGetLanguageAndRegionCodes(SInt32 *languageCode, SInt32 *regionCode); -// may return -1 for either one if no code can be found - -CF_EXPORT -Boolean CFBundleGetLocalizationInfoForLocalization(CFStringRef localizationName, SInt32 *languageCode, SInt32 *regionCode, SInt32 *scriptCode, CFStringEncoding *stringEncoding); - /* Gets the appropriate language and region codes, and the default */ - /* script code and encoding, for the localization specified. */ - /* Pass NULL for the localizationName to get these values for the */ - /* single most preferred localization in the current context. */ - /* May give -1 if there is no language or region code for a particular */ - /* localization. Returns false if CFBundle has no information about */ - /* the given localization. */ - -CF_EXPORT -CFStringRef CFBundleCopyLocalizationForLocalizationInfo(SInt32 languageCode, SInt32 regionCode, SInt32 scriptCode, CFStringEncoding stringEncoding); - /* Returns the default localization for the combination of codes */ - /* specified. Pass in -1 for language, region code, or script code, or */ - /* 0xFFFF for stringEncoding, if you do not wish to specify one of these. */ - -// Get a localized string for a specific localization (including processing as strings dict file). This skips the usual cache for localized strings. -CF_EXPORT CFStringRef CFBundleCopyLocalizedStringForLocalization(CFBundleRef bundle, CFStringRef key, CFStringRef value, CFStringRef tableName, CFStringRef localizationName) CF_AVAILABLE(10_10, 8_0); - -CF_EXPORT -void _CFBundleSetDefaultLocalization(CFStringRef localizationName); - - -/* Functions for dealing specifically with CFM executables */ - -CF_EXPORT -void *_CFBundleGetCFMFunctionPointerForName(CFBundleRef bundle, CFStringRef funcName); - -CF_EXPORT -void _CFBundleGetCFMFunctionPointersForNames(CFBundleRef bundle, CFArrayRef functionNames, void *ftbl[]); - -CF_EXPORT -void _CFBundleSetCFMConnectionID(CFBundleRef bundle, void *connectionID); - - -/* Miscellaneous functions */ - -CF_EXPORT -CFStringRef _CFBundleCopyFileTypeForFileURL(CFURLRef url); - -CF_EXPORT -CFStringRef _CFBundleCopyFileTypeForFileData(CFDataRef data); - -CF_EXPORT -Boolean _CFBundleGetHasChanged(CFBundleRef bundle); - -CF_EXPORT -void _CFBundleFlushCaches(void) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXPORT -void _CFBundleFlushCachesForURL(CFURLRef url) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXPORT -void _CFBundleFlushBundleCaches(CFBundleRef bundle); // The previous two functions flush cached resource paths; this one also flushes bundle-specific caches such as the info dictionary and strings files - -CF_EXPORT -CFArrayRef _CFBundleCopyAllBundles(void); // Pending publication, the only known client of this is PowerBox. Email david_smith@apple.com before using this. - -CF_EXPORT -void _CFBundleSetStringsFilesShared(CFBundleRef bundle, Boolean flag); - -CF_EXPORT -Boolean _CFBundleGetStringsFilesShared(CFBundleRef bundle); - -CF_EXPORT -CFURLRef _CFBundleCopyFrameworkURLForExecutablePath(CFStringRef executablePath); - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -#include -CF_EXPORT -void _CFBundleSetupXPCBootstrap(xpc_object_t bootstrap) CF_AVAILABLE(10_10, 8_0); -#endif - -/* Functions deprecated as SPI */ - -CF_EXPORT -CFDictionaryRef _CFBundleGetLocalInfoDictionary(CFBundleRef bundle); // deprecated in favor of CFBundleGetLocalInfoDictionary - -CF_EXPORT -CFPropertyListRef _CFBundleGetValueForInfoKey(CFBundleRef bundle, CFStringRef key); // deprecated in favor of CFBundleGetValueForInfoDictionaryKey - -CF_EXPORT -Boolean _CFBundleGetPackageInfoInDirectory(CFAllocatorRef alloc, CFURLRef url, UInt32 *packageType, UInt32 *packageCreator); // deprecated in favor of CFBundleGetPackageInfoInDirectory - -CF_EXPORT -CFDictionaryRef _CFBundleCopyInfoDictionaryInResourceFork(CFURLRef url); // CFBundleCopyInfoDictionaryForURL is usually preferred; for the main bundle, however, no special call is necessary, since the info dictionary will automatically be available whether the app is bundled or not - -CF_EXPORT -CFURLRef _CFBundleCopyPrivateFrameworksURL(CFBundleRef bundle); // deprecated in favor of CFBundleCopyPrivateFrameworksURL - -CF_EXPORT -CFURLRef _CFBundleCopySharedFrameworksURL(CFBundleRef bundle); // deprecated in favor of CFBundleCopySharedFrameworksURL - -CF_EXPORT -CFURLRef _CFBundleCopySharedSupportURL(CFBundleRef bundle); // deprecated in favor of CFBundleCopySharedSupportURL - -CF_EXPORT -CFURLRef _CFBundleCopyBuiltInPlugInsURL(CFBundleRef bundle); // deprecated in favor of CFBundleCopyBuiltInPlugInsURL - -CF_EXPORT -CFURLRef _CFBundleCopyResourceURLForLanguage(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName, CFStringRef language); // deprecated in favor of CFBundleCopyResourceURLForLocalization - -CF_EXPORT -CFArrayRef _CFBundleCopyResourceURLsOfTypeForLanguage(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName, CFStringRef language); // deprecated in favor of CFBundleCopyResourceURLsOfTypeForLocalization - -CF_EXPORT -CFBundleRefNum _CFBundleOpenBundleResourceFork(CFBundleRef bundle); // deprecated in favor of CFBundleOpenBundleResourceMap - -CF_EXPORT -void _CFBundleCloseBundleResourceFork(CFBundleRef bundle); // deprecated in favor of CFBundleCloseBundleResourceMap - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFBUNDLEPRIV__ */ - diff --git a/CFBundlePriv.h b/CFBundlePriv.h new file mode 120000 index 0000000..54e4dc0 --- /dev/null +++ b/CFBundlePriv.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBundlePriv.h \ No newline at end of file diff --git a/CFBundle_BinaryTypes.h b/CFBundle_BinaryTypes.h deleted file mode 100644 index fc3f4b4..0000000 --- a/CFBundle_BinaryTypes.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBundle_BinaryTypes.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFBUNDLE_BINARYTYPES__) -#define __COREFOUNDATION_CFBUNDLE_BINARYTYPES__ 1 - -CF_EXTERN_C_BEGIN - -#if DEPLOYMENT_TARGET_MACOSX -#define BINARY_SUPPORT_DYLD 1 -#define BINARY_SUPPORT_DLFCN 1 -#define USE_DYLD_PRIV 1 -#elif DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI -#define BINARY_SUPPORT_DYLD 1 -#define BINARY_SUPPORT_DLFCN 1 -#define USE_DYLD_PRIV 1 -#elif DEPLOYMENT_TARGET_WINDOWS -#define BINARY_SUPPORT_DLL 1 -#else -#error Unknown or unspecified DEPLOYMENT_TARGET -#endif - - -typedef enum { - __CFBundleUnknownBinary, - __CFBundleCFMBinary, - __CFBundleDYLDExecutableBinary, - __CFBundleDYLDBundleBinary, - __CFBundleDYLDFrameworkBinary, - __CFBundleDLLBinary, - __CFBundleUnreadableBinary, - __CFBundleNoBinary, - __CFBundleELFBinary -} __CFPBinaryType; - -/* Intended for eventual public consumption */ -typedef enum { - kCFBundleOtherExecutableType = 0, - kCFBundleMachOExecutableType, - kCFBundlePEFExecutableType, - kCFBundleELFExecutableType, - kCFBundleDLLExecutableType -} CFBundleExecutableType; - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFBUNDLE_BINARYTYPES__ */ - diff --git a/CFBundle_BinaryTypes.h b/CFBundle_BinaryTypes.h new file mode 120000 index 0000000..0360663 --- /dev/null +++ b/CFBundle_BinaryTypes.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBundle_BinaryTypes.h \ No newline at end of file diff --git a/CFBundle_Internal.h b/CFBundle_Internal.h deleted file mode 100644 index 8cb5bec..0000000 --- a/CFBundle_Internal.h +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBundle_Internal.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFBUNDLE_INTERNAL__) -#define __COREFOUNDATION_CFBUNDLE_INTERNAL__ 1 - -#include -#include -#include -#include -#include "CFInternal.h" -#include "CFPlugIn_Factory.h" -#include "CFBundle_BinaryTypes.h" -#include "CFByteOrder.h" - -CF_EXTERN_C_BEGIN - -#define __kCFLogBundle 3 -#define __kCFLogPlugIn 3 - -#if DEPLOYMENT_TARGET_WINDOWS -#define PLATFORM_PATH_STYLE kCFURLWindowsPathStyle -#else -#define PLATFORM_PATH_STYLE kCFURLPOSIXPathStyle -#endif - -#define CFBundleExecutableNotFoundError 4 -#define CFBundleExecutableNotLoadableError 3584 -#define CFBundleExecutableArchitectureMismatchError 3585 -#define CFBundleExecutableRuntimeMismatchError 3586 -#define CFBundleExecutableLoadError 3587 -#define CFBundleExecutableLinkError 3588 - -CF_INLINE uint32_t _CFBundleSwapInt32Conditional(uint32_t arg, Boolean swap) {return swap ? CFSwapInt32(arg) : arg;} -CF_INLINE uint32_t _CFBundleSwapInt64Conditional(uint64_t arg, Boolean swap) {return swap ? CFSwapInt64(arg) : arg;} - -// uncomment this to enable the checking for 8302591 -//#define CFBUNDLE_NO_TRAVERSE_OUTSIDE - -typedef struct __CFResourceData { - Boolean _executableLacksResourceFork; - Boolean _infoDictionaryFromResourceFork; - char _padding[2]; -} _CFResourceData; - -CF_PRIVATE _CFResourceData *__CFBundleGetResourceData(CFBundleRef bundle); - -typedef struct __CFPlugInData { - Boolean _isPlugIn; - Boolean _loadOnDemand; - Boolean _isDoingDynamicRegistration; - Boolean _unused1; - UInt32 _instanceCount; - CFMutableArrayRef _factories; -} _CFPlugInData; - -struct __CFBundle { - CFRuntimeBase _base; - - CFURLRef _url; - CFDateRef _modDate; - - __strong CFDictionaryRef _infoDict; - __strong CFDictionaryRef _localInfoDict; - CFArrayRef _searchLanguages; - - __CFPBinaryType _binaryType; - Boolean _isLoaded; - uint8_t _version; - Boolean _sharesStringsFiles; - char _padding[1]; - - /* CFM goop */ - void *_connectionCookie; - - /* DYLD goop */ - const void *_imageCookie; - const void *_moduleCookie; - - /* dlfcn goop */ - void *_handleCookie; - - /* CFM<->DYLD glue */ - CFMutableDictionaryRef _glueDict; - - /* Resource fork goop */ - _CFResourceData _resourceData; - - _CFPlugInData _plugInData; - - pthread_mutex_t _bundleLoadingLock; - - CFStringRef _executablePath; // Calculated and cached here - CFStringRef _developmentRegion; // Calculated and cached here - dispatch_once_t _developmentRegionCalculated; - - CFLock_t _lock; - - CFArrayRef _localizations; // List of localizations, including the development language fallback if required - Boolean _lookedForLocalizations; - - CFMutableDictionaryRef _resourceDirectoryContents; - - CFMutableDictionaryRef _stringTable; - - CFLock_t _queryLock; - CFMutableDictionaryRef _queryTable; - CFStringRef _bundleBasePath; - -#if defined(BINARY_SUPPORT_DLL) - HMODULE _hModule; -#endif /* BINARY_SUPPORT_DLL */ - -}; - -extern _CFPlugInData *__CFBundleGetPlugInData(CFBundleRef bundle); - -/* Private CFBundle API */ - -CF_PRIVATE CFErrorRef _CFBundleCreateErrorDebug(CFAllocatorRef allocator, CFBundleRef bundle, CFIndex code, CFStringRef debugString); - -CF_PRIVATE void _CFBundleInfoPlistProcessInfoDictionary(CFMutableDictionaryRef dict); -CF_PRIVATE Boolean _CFBundleSupportedProductName(CFStringRef fileName, CFRange searchRange); -CF_PRIVATE Boolean _CFBundleSupportedPlatformName(CFStringRef fileName, CFRange searchRange); - -CF_EXPORT CFStringRef _CFGetProductName(void); -CF_EXPORT CFStringRef _CFGetPlatformName(void); -CF_EXPORT CFStringRef _CFGetAlternatePlatformName(void); - -CF_PRIVATE void _CFBundleFlushQueryTableCache(CFBundleRef bundle); - -CF_PRIVATE SInt32 _CFBundleCurrentArchitecture(void); -CF_PRIVATE Boolean _CFBundleGetObjCImageInfo(CFBundleRef bundle, uint32_t *objcVersion, uint32_t *objcFlags); - -#if defined(BINARY_SUPPORT_DYLD) -CF_PRIVATE CFMutableDictionaryRef _CFBundleCreateInfoDictFromMainExecutable(); -CF_PRIVATE Boolean _CFBundleGrokObjCImageInfoFromMainExecutable(uint32_t *objcVersion, uint32_t *objcFlags); -#endif - -CF_PRIVATE CFStringRef _CFBundleCopyLoadedImagePathForPointer(void *p); - -// Languages and locales - -CF_PRIVATE CFArrayRef _CFBundleCopyLanguageSearchListInDirectory(CFURLRef url, uint8_t *version); -CF_PRIVATE CFArrayRef _CFBundleCopyLanguageSearchListInBundle(CFBundleRef bundle); - -CF_PRIVATE Boolean CFBundleAllowMixedLocalizations(void); - -// Misc - -extern Boolean _CFIsResourceAtURL(CFURLRef url, Boolean *isDir); -extern Boolean _CFIsResourceAtPath(CFStringRef path, Boolean *isDir); - -CF_PRIVATE uint8_t _CFBundleGetBundleVersionForURL(CFURLRef url); -extern CFDictionaryRef _CFBundleCopyInfoDictionaryInDirectory(CFAllocatorRef alloc, CFURLRef url, UInt8 *version); -extern CFDictionaryRef _CFBundleCopyInfoDictionaryInDirectoryWithVersion(CFAllocatorRef alloc, CFURLRef url, UInt8 version); -extern CFURLRef _CFBundleCopySupportFilesDirectoryURLInDirectory(CFURLRef bundleURL, UInt8 version); -extern CFURLRef _CFBundleCopyResourcesDirectoryURLInDirectory(CFURLRef bundleURL, UInt8 version); - -extern Boolean _CFBundleCouldBeBundle(CFURLRef url); -extern CFDictionaryRef _CFBundleCopyInfoDictionaryInResourceForkWithAllocator(CFAllocatorRef alloc, CFURLRef url); -CF_PRIVATE CFStringRef _CFBundleCopyExecutableName(CFBundleRef bundle, CFURLRef url, CFDictionaryRef infoDict); -#if DEPLOYMENT_TARGET_MACOSX -CF_PRIVATE CFStringRef _CFBundleCopyBundleDevelopmentRegionFromVersResource(CFBundleRef bundle); -#endif -extern CFDictionaryRef _CFBundleCopyInfoDictionaryInExecutable(CFURLRef url); -extern CFArrayRef _CFBundleCopyArchitecturesForExecutable(CFURLRef url); - -extern CFStringRef _CFBundleGetPlatformExecutablesSubdirectoryName(void); -extern CFStringRef _CFBundleGetAlternatePlatformExecutablesSubdirectoryName(void); -extern CFStringRef _CFBundleGetOtherPlatformExecutablesSubdirectoryName(void); -extern CFStringRef _CFBundleGetOtherAlternatePlatformExecutablesSubdirectoryName(void); - -extern CFStringRef _CFCreateStringFromVersionNumber(CFAllocatorRef alloc, UInt32 vers); -extern UInt32 _CFVersionNumberFromString(CFStringRef versStr); - -extern void _CFBundleScheduleForUnloading(CFBundleRef bundle); -extern void _CFBundleUnscheduleForUnloading(CFBundleRef bundle); -extern void _CFBundleUnloadScheduledBundles(void); - -CF_PRIVATE void _CFBundleAppendResourceDir(CFMutableStringRef path, uint8_t version); - -CF_PRIVATE UInt8 _CFBundleLayoutVersion(CFBundleRef bundle); - -#if defined(BINARY_SUPPORT_DYLD) -// DYLD API -extern __CFPBinaryType _CFBundleGrokBinaryType(CFURLRef executableURL); -extern CFArrayRef _CFBundleDYLDCopyLoadedImagePathsIfChanged(void); -extern CFArrayRef _CFBundleDYLDCopyLoadedImagePathsForHint(CFStringRef hint); -#if !defined(BINARY_SUPPORT_DLFCN) -extern Boolean _CFBundleDYLDCheckLoaded(CFBundleRef bundle); -extern Boolean _CFBundleDYLDLoadBundle(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error); -extern Boolean _CFBundleDYLDLoadFramework(CFBundleRef bundle, CFErrorRef *error); -extern void _CFBundleDYLDUnloadBundle(CFBundleRef bundle); -extern void *_CFBundleDYLDGetSymbolByName(CFBundleRef bundle, CFStringRef symbolName); -#endif /* !BINARY_SUPPORT_DLFCN */ -#endif /* BINARY_SUPPORT_DYLD */ - -#if defined(BINARY_SUPPORT_DLFCN) -// dlfcn API -extern Boolean _CFBundleDlfcnCheckLoaded(CFBundleRef bundle); -extern Boolean _CFBundleDlfcnPreflight(CFBundleRef bundle, CFErrorRef *error); -extern Boolean _CFBundleDlfcnLoadBundle(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error); -extern Boolean _CFBundleDlfcnLoadFramework(CFBundleRef bundle, CFErrorRef *error); -extern void _CFBundleDlfcnUnload(CFBundleRef bundle); -extern void *_CFBundleDlfcnGetSymbolByName(CFBundleRef bundle, CFStringRef symbolName); -#endif /* BINARY_SUPPORT_DLFCN */ - -#if defined(BINARY_SUPPORT_DLL) -extern Boolean _CFBundleDLLLoad(CFBundleRef bundle, CFErrorRef *error); -extern void _CFBundleDLLUnload(CFBundleRef bundle); -extern void *_CFBundleDLLGetSymbolByName(CFBundleRef bundle, CFStringRef symbolName); -#endif /* BINARY_SUPPORT_DLL */ - - -/* Private PlugIn-related CFBundle API */ - -extern Boolean _CFBundleNeedsInitPlugIn(CFBundleRef bundle); -extern void _CFBundleInitPlugIn(CFBundleRef bundle); -extern void _CFBundlePlugInLoaded(CFBundleRef bundle); -extern void _CFBundleDeallocatePlugIn(CFBundleRef bundle); - -extern void _CFPlugInWillUnload(CFPlugInRef plugIn); - -extern void _CFPlugInAddPlugInInstance(CFPlugInRef plugIn); -extern void _CFPlugInRemovePlugInInstance(CFPlugInRef plugIn); - -extern void _CFPlugInAddFactory(CFPlugInRef plugIn, _CFPFactoryRef factory); -extern void _CFPlugInRemoveFactory(CFPlugInRef plugIn, _CFPFactoryRef factory); - - -/* Strings for parsing bundle structure */ -#define _CFBundleSupportFilesDirectoryName1 CFSTR("Support Files") -#define _CFBundleSupportFilesDirectoryName2 CFSTR("Contents") -#define _CFBundleResourcesDirectoryName CFSTR("Resources") -#define _CFBundleExecutablesDirectoryName CFSTR("Executables") -#define _CFBundleNonLocalizedResourcesDirectoryName CFSTR("Non-localized Resources") - -#if DEPLOYMENT_TARGET_WINDOWS -#define _CFBundleSupportFilesDirectoryName1WithResources CFSTR("Support Files\\Resources") -#define _CFBundleSupportFilesDirectoryName2WithResources CFSTR("Contents\\Resources") -#else -#define _CFBundleSupportFilesDirectoryName1WithResources CFSTR("Support Files/Resources") -#define _CFBundleSupportFilesDirectoryName2WithResources CFSTR("Contents/Resources") -#endif - -#define _CFBundleSupportFilesURLFromBase1 CFSTR("Support%20Files/") -#define _CFBundleSupportFilesURLFromBase2 CFSTR("Contents/") -#define _CFBundleResourcesURLFromBase0 CFSTR("Resources/") -#define _CFBundleResourcesURLFromBase1 CFSTR("Support%20Files/Resources/") -#define _CFBundleResourcesURLFromBase2 CFSTR("Contents/Resources/") -#define _CFBundleAppStoreReceiptURLFromBase0 CFSTR("_MASReceipt/receipt") -#define _CFBundleAppStoreReceiptURLFromBase1 CFSTR("Support%20Files/_MASReceipt/receipt") -#define _CFBundleAppStoreReceiptURLFromBase2 CFSTR("Contents/_MASReceipt/receipt") -#define _CFBundleExecutablesURLFromBase1 CFSTR("Support%20Files/Executables/") -#define _CFBundleExecutablesURLFromBase2 CFSTR("Contents/") - -#define _CFBundleInfoURLFromBase0 CFSTR("Resources/Info.plist") -#define _CFBundleInfoURLFromBase1 CFSTR("Support%20Files/Info.plist") -#define _CFBundleInfoURLFromBase2 CFSTR("Contents/Info.plist") -#define _CFBundleInfoURLFromBase3 CFSTR("Info.plist") -#define _CFBundleInfoURLFromBaseNoExtension3 CFSTR("Info") - -#if DEPLOYMENT_TARGET_MACOSX -#define _CFBundlePlatformInfoURLFromBase0 CFSTR("Resources/Info-macos.plist") -#define _CFBundlePlatformInfoURLFromBase1 CFSTR("Support%20Files/Info-macos.plist") -#define _CFBundlePlatformInfoURLFromBase2 CFSTR("Contents/Info-macos.plist") -#define _CFBundlePlatformInfoURLFromBase3 CFSTR("Info-macos.plist") -#elif DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI -#define _CFBundlePlatformInfoURLFromBase0 CFSTR("Resources/Info-iphoneos.plist") -#define _CFBundlePlatformInfoURLFromBase1 CFSTR("Support%20Files/Info-iphoneos.plist") -#define _CFBundlePlatformInfoURLFromBase2 CFSTR("Contents/Info-iphoneos.plist") -#define _CFBundlePlatformInfoURLFromBase3 CFSTR("Info-iphoneos.plist") -#else -// No platform-specific variants in these cases -#define _CFBundlePlatformInfoURLFromBase0 _CFBundleInfoURLFromBase0 -#define _CFBundlePlatformInfoURLFromBase1 _CFBundleInfoURLFromBase1 -#define _CFBundlePlatformInfoURLFromBase2 _CFBundleInfoURLFromBase2 -#define _CFBundlePlatformInfoURLFromBase3 _CFBundleInfoURLFromBase3 -#endif - -#define _CFBundleInfoPlistName CFSTR("Info.plist") - -#if DEPLOYMENT_TARGET_MACOSX -#define _CFBundlePlatformInfoPlistName CFSTR("Info-macos.plist") -#elif DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI -#define _CFBundlePlatformInfoPlistName CFSTR("Info-iphoneos.plist") -#else -// No platform-specific Info.plist for these -#define _CFBundlePlatformInfoPlistName _CFBundleInfoPlistName -#endif - -#define _CFBundleInfoExtension CFSTR("plist") -#define _CFBundleLocalInfoName CFSTR("InfoPlist") -#define _CFBundlePkgInfoURLFromBase1 CFSTR("Support%20Files/PkgInfo") -#define _CFBundlePkgInfoURLFromBase2 CFSTR("Contents/PkgInfo") -#define _CFBundlePseudoPkgInfoURLFromBase CFSTR("PkgInfo") -#define _CFBundlePrivateFrameworksURLFromBase0 CFSTR("Frameworks/") -#define _CFBundlePrivateFrameworksURLFromBase1 CFSTR("Support%20Files/Frameworks/") -#define _CFBundlePrivateFrameworksURLFromBase2 CFSTR("Contents/Frameworks/") -#define _CFBundleSharedFrameworksURLFromBase0 CFSTR("SharedFrameworks/") -#define _CFBundleSharedFrameworksURLFromBase1 CFSTR("Support%20Files/SharedFrameworks/") -#define _CFBundleSharedFrameworksURLFromBase2 CFSTR("Contents/SharedFrameworks/") -#define _CFBundleSharedSupportURLFromBase0 CFSTR("SharedSupport/") -#define _CFBundleSharedSupportURLFromBase1 CFSTR("Support%20Files/SharedSupport/") -#define _CFBundleSharedSupportURLFromBase2 CFSTR("Contents/SharedSupport/") -#define _CFBundleBuiltInPlugInsURLFromBase0 CFSTR("PlugIns/") -#define _CFBundleBuiltInPlugInsURLFromBase1 CFSTR("Support%20Files/PlugIns/") -#define _CFBundleBuiltInPlugInsURLFromBase2 CFSTR("Contents/PlugIns/") -#define _CFBundleAlternateBuiltInPlugInsURLFromBase0 CFSTR("Plug-ins/") -#define _CFBundleAlternateBuiltInPlugInsURLFromBase1 CFSTR("Support%20Files/Plug-ins/") -#define _CFBundleAlternateBuiltInPlugInsURLFromBase2 CFSTR("Contents/Plug-ins/") - -#define _CFBundleLprojExtension CFSTR("lproj") -#define _CFBundleLprojExtensionWithDot CFSTR(".lproj") -#define _CFBundleDot CFSTR(".") -#define _CFBundleAllFiles CFSTR("_CFBAF_") -#define _CFBundleTypeIndicator CFSTR("_CFBT_") -// This directory contains resources (especially nibs) that may look up localized resources or may fall back to the development language resources -#define _CFBundleBaseDirectory CFSTR("Base") - -#define _CFBundleMacOSXPlatformName CFSTR("macos") -#define _CFBundleAlternateMacOSXPlatformName CFSTR("macosx") -#define _CFBundleiPhoneOSPlatformName CFSTR("iphoneos") -#define _CFBundleMacOS8PlatformName CFSTR("macosclassic") -#define _CFBundleAlternateMacOS8PlatformName CFSTR("macos8") -#define _CFBundleWindowsPlatformName CFSTR("windows") -#define _CFBundleHPUXPlatformName CFSTR("hpux") -#define _CFBundleSolarisPlatformName CFSTR("solaris") -#define _CFBundleLinuxPlatformName CFSTR("linux") -#define _CFBundleFreeBSDPlatformName CFSTR("freebsd") - -#define _CFBundleDefaultStringTableName CFSTR("Localizable") -#define _CFBundleStringTableType CFSTR("strings") -#define _CFBundleStringDictTableType CFSTR("stringsdict") - -#define _CFBundleUserLanguagesPreferenceName CFSTR("AppleLanguages") -#define _CFBundleOldUserLanguagesPreferenceName CFSTR("NSLanguages") - -#define _CFBundleLocalizedResourceForkFileName CFSTR("Localized") - -#define _CFBundleWindowsResourceDirectoryExtension CFSTR("resources") - -#define _CFBundleMacOSXInfoPlistPlatformName_OLD CFSTR("macos") -#define _CFBundleWindowsInfoPlistPlatformName_OLD CFSTR("win32") - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFBUNDLE_INTERNAL__ */ - diff --git a/CFBundle_Internal.h b/CFBundle_Internal.h new file mode 120000 index 0000000..311d5a7 --- /dev/null +++ b/CFBundle_Internal.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBundle_Internal.h \ No newline at end of file diff --git a/CFBurstTrie.h b/CFBurstTrie.h deleted file mode 100644 index 852e022..0000000 --- a/CFBurstTrie.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFBurstTrie.h - Copyright (c) 2008-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFBURSTTRIE__) -#define __COREFOUNDATION_CFBURSTTRIE__ 1 - -#include -#include - -CF_EXTERN_C_BEGIN - -typedef struct _CFBurstTrie *CFBurstTrieRef; -typedef struct _CFBurstTrieCursor *CFBurstTrieCursorRef; - -typedef CF_OPTIONS(CFOptionFlags, CFBurstTrieOpts) { - /*! - BurstTrie Options - Use one or more of these options with CFBurstTrieCreate to tailor optimizations to the data - structure for a specific kind of application. Default is no read-write, no compression. - */ - - /* kCFBurstTrieReadOnly - When specified, the dictionary file will be serialized in an optimized format so as to be - memory-mapped on the next read. Once a trie is serialized as read-only, insertions can no - longer occur. - */ - kCFBurstTrieReadOnly = 1<<1, - - /* kCFBurstTrieBitmapCompression - This option can only be used with a read-only trie, and can be used to reduce on disk file size. - */ - kCFBurstTrieBitmapCompression = 1<<2, - - /* - kCFBurstTriePrefixCompression - This option can only be used with a read-only trie, and can be used to reduce on-disk file size. - It is important to note that any optimizations based on word frequency will be lost; recommended - for applications that often search for infrequent or uncommon words. This also allow you to use - cursor interface. - */ - kCFBurstTriePrefixCompression = 1<<3, - - /* - kCFBurstTriePrefixCompression - By default, keys at list level are sorted by weight. Use this option to sort them by key value. - This allow you to use cursor interface. - */ - kCFBurstTrieSortByKey = 1 << 4 -}; - -// Value for this option should be a CFNumber which contains an int. -#define kCFBurstTrieCreationOptionNameContainerSize CFSTR("ContainerSize") - -typedef void (*CFBurstTrieTraversalCallback)(void* context, const UInt8* key, uint32_t keyLength, uint32_t payload, Boolean *stop); - -CF_EXPORT -CFBurstTrieRef CFBurstTrieCreate() CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -CFBurstTrieRef CFBurstTrieCreateWithOptions(CFDictionaryRef options) CF_AVAILABLE(10_8, 6_0); - -CF_EXPORT -CFBurstTrieRef CFBurstTrieCreateFromFile(CFStringRef path) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -CFBurstTrieRef CFBurstTrieCreateFromMapBytes(char *mapBase) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieInsert(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, CFIndex payload) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieAdd(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, uint32_t payload) CF_AVAILABLE(10_7, 5_0); - - -CF_EXPORT -Boolean CFBurstTrieInsertCharacters(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, CFIndex payload) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieAddCharacters(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, uint32_t payload) CF_AVAILABLE(10_7, 5_0); - - -CF_EXPORT -Boolean CFBurstTrieInsertUTF8String(CFBurstTrieRef trie, UInt8 *chars, CFIndex numChars, CFIndex payload) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieAddUTF8String(CFBurstTrieRef trie, UInt8 *chars, CFIndex numChars, uint32_t payload) CF_AVAILABLE(10_7, 5_0); - - -CF_EXPORT -Boolean CFBurstTrieInsertWithWeight(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, CFIndex weight, CFIndex payload) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieAddWithWeight(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, uint32_t weight, uint32_t payload) CF_AVAILABLE(10_7, 5_0); - - -CF_EXPORT -Boolean CFBurstTrieInsertCharactersWithWeight(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, CFIndex weight, CFIndex payload) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieAddCharactersWithWeight(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, uint32_t weight, uint32_t payload) CF_AVAILABLE(10_7, 5_0); - - -CF_EXPORT -Boolean CFBurstTrieInsertUTF8StringWithWeight(CFBurstTrieRef trie, UInt8 *chars, CFIndex numChars, CFIndex weight, CFIndex payload) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieAddUTF8StringWithWeight(CFBurstTrieRef trie, UInt8 *chars, CFIndex numChars, uint32_t weight, uint32_t payload) CF_AVAILABLE(10_7, 5_0); - - -CF_EXPORT -Boolean CFBurstTrieFind(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, CFIndex *payload) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieContains(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, uint32_t *payload) CF_AVAILABLE(10_7, 5_0); - - -CF_EXPORT -Boolean CFBurstTrieFindCharacters(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, CFIndex *payload) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieContainsCharacters(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, uint32_t *payload) CF_AVAILABLE(10_7, 5_0); - - -CF_EXPORT -Boolean CFBurstTrieFindUTF8String(CFBurstTrieRef trie, UInt8 *key, CFIndex length, CFIndex *payload) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieContainsUTF8String(CFBurstTrieRef trie, UInt8 *key, CFIndex length, uint32_t *payload) CF_AVAILABLE(10_7, 5_0); - - -CF_EXPORT -Boolean CFBurstTrieSerialize(CFBurstTrieRef trie, CFStringRef path, CFBurstTrieOpts opts) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFBurstTrieSerializeWithFileDescriptor(CFBurstTrieRef trie, int fd, CFBurstTrieOpts opts) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -void CFBurstTrieTraverse(CFBurstTrieRef trie, void *ctx, void (*callback)(void*, const UInt8*, uint32_t, uint32_t)) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -CFIndex CFBurstTrieGetCount(CFBurstTrieRef trie) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -CFBurstTrieRef CFBurstTrieRetain(CFBurstTrieRef trie) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -void CFBurstTrieRelease(CFBurstTrieRef trie) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -CFBurstTrieCursorRef CFBurstTrieCreateCursorForBytes(CFBurstTrieRef trie, const UInt8* bytes, CFIndex length) CF_AVAILABLE(10_8, 6_0); - -CF_EXPORT -CFBurstTrieCursorRef CFBurstTrieCursorCreateByCopy(CFBurstTrieCursorRef cursor) CF_AVAILABLE(10_8, 6_0); - -CF_EXPORT -Boolean CFBurstTrieSetCursorForBytes(CFBurstTrieRef trie, CFBurstTrieCursorRef cursor, const UInt8* bytes, CFIndex length) CF_AVAILABLE(10_8, 6_0); - -CF_EXPORT -Boolean CFBurstTrieCursorIsEqual(CFBurstTrieCursorRef lhs, CFBurstTrieCursorRef rhs) CF_AVAILABLE(10_8, 6_0); - -CF_EXPORT -Boolean CFBurstTrieCursorAdvanceForBytes(CFBurstTrieCursorRef cursor, const UInt8* bytes, CFIndex length) CF_AVAILABLE(10_8, 6_0); - -CF_EXPORT -Boolean CFBurstTrieCursorGetPayload(CFBurstTrieCursorRef cursor, uint32_t *payload) CF_AVAILABLE(10_8, 6_0); - -CF_EXPORT -void CFBurstTrieTraverseFromCursor(CFBurstTrieCursorRef cursor, void *ctx, CFBurstTrieTraversalCallback callback) CF_AVAILABLE(10_8, 6_0); - -CF_EXPORT -void CFBurstTrieCursorRelease(CFBurstTrieCursorRef cursor) CF_AVAILABLE(10_8, 6_0); - -CF_EXTERN_C_END - -#endif /* __COREFOUNDATION_CFBURSTTRIE__ */ diff --git a/CFBurstTrie.h b/CFBurstTrie.h new file mode 120000 index 0000000..927a498 --- /dev/null +++ b/CFBurstTrie.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFBurstTrie.h \ No newline at end of file diff --git a/CFByteOrder.h b/CFByteOrder.h deleted file mode 100644 index 7858572..0000000 --- a/CFByteOrder.h +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFByteOrder.h - Copyright (c) 1995-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFBYTEORDER__) -#define __COREFOUNDATION_CFBYTEORDER__ 1 - -#include -#if ((TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) && !defined(CF_USE_OSBYTEORDER_H) -#include -#define CF_USE_OSBYTEORDER_H 1 -#endif - -CF_EXTERN_C_BEGIN - -enum __CFByteOrder { - CFByteOrderUnknown, - CFByteOrderLittleEndian, - CFByteOrderBigEndian -}; -typedef CFIndex CFByteOrder; - -CF_INLINE CFByteOrder CFByteOrderGetCurrent(void) { -#if CF_USE_OSBYTEORDER_H - int32_t byteOrder = OSHostByteOrder(); - switch (byteOrder) { - case OSLittleEndian: return CFByteOrderLittleEndian; - case OSBigEndian: return CFByteOrderBigEndian; - default: break; - } - return CFByteOrderUnknown; -#else -#if __LITTLE_ENDIAN__ - return CFByteOrderLittleEndian; -#elif __BIG_ENDIAN__ - return CFByteOrderBigEndian; -#else - return CFByteOrderUnknown; -#endif -#endif -} - -CF_INLINE uint16_t CFSwapInt16(uint16_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapInt16(arg); -#else - uint16_t result; - result = (uint16_t)(((arg << 8) & 0xFF00) | ((arg >> 8) & 0xFF)); - return result; -#endif -} - -CF_INLINE uint32_t CFSwapInt32(uint32_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapInt32(arg); -#else - uint32_t result; - result = ((arg & 0xFF) << 24) | ((arg & 0xFF00) << 8) | ((arg >> 8) & 0xFF00) | ((arg >> 24) & 0xFF); - return result; -#endif -} - -CF_INLINE uint64_t CFSwapInt64(uint64_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapInt64(arg); -#else - union CFSwap { - uint64_t sv; - uint32_t ul[2]; - } tmp, result; - tmp.sv = arg; - result.ul[0] = CFSwapInt32(tmp.ul[1]); - result.ul[1] = CFSwapInt32(tmp.ul[0]); - return result.sv; -#endif -} - -CF_INLINE uint16_t CFSwapInt16BigToHost(uint16_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapBigToHostInt16(arg); -#elif __BIG_ENDIAN__ - return arg; -#else - return CFSwapInt16(arg); -#endif -} - -CF_INLINE uint32_t CFSwapInt32BigToHost(uint32_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapBigToHostInt32(arg); -#elif __BIG_ENDIAN__ - return arg; -#else - return CFSwapInt32(arg); -#endif -} - -CF_INLINE uint64_t CFSwapInt64BigToHost(uint64_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapBigToHostInt64(arg); -#elif __BIG_ENDIAN__ - return arg; -#else - return CFSwapInt64(arg); -#endif -} - -CF_INLINE uint16_t CFSwapInt16HostToBig(uint16_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapHostToBigInt16(arg); -#elif __BIG_ENDIAN__ - return arg; -#else - return CFSwapInt16(arg); -#endif -} - -CF_INLINE uint32_t CFSwapInt32HostToBig(uint32_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapHostToBigInt32(arg); -#elif __BIG_ENDIAN__ - return arg; -#else - return CFSwapInt32(arg); -#endif -} - -CF_INLINE uint64_t CFSwapInt64HostToBig(uint64_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapHostToBigInt64(arg); -#elif __BIG_ENDIAN__ - return arg; -#else - return CFSwapInt64(arg); -#endif -} - -CF_INLINE uint16_t CFSwapInt16LittleToHost(uint16_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapLittleToHostInt16(arg); -#elif __LITTLE_ENDIAN__ - return arg; -#else - return CFSwapInt16(arg); -#endif -} - -CF_INLINE uint32_t CFSwapInt32LittleToHost(uint32_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapLittleToHostInt32(arg); -#elif __LITTLE_ENDIAN__ - return arg; -#else - return CFSwapInt32(arg); -#endif -} - -CF_INLINE uint64_t CFSwapInt64LittleToHost(uint64_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapLittleToHostInt64(arg); -#elif __LITTLE_ENDIAN__ - return arg; -#else - return CFSwapInt64(arg); -#endif -} - -CF_INLINE uint16_t CFSwapInt16HostToLittle(uint16_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapHostToLittleInt16(arg); -#elif __LITTLE_ENDIAN__ - return arg; -#else - return CFSwapInt16(arg); -#endif -} - -CF_INLINE uint32_t CFSwapInt32HostToLittle(uint32_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapHostToLittleInt32(arg); -#elif __LITTLE_ENDIAN__ - return arg; -#else - return CFSwapInt32(arg); -#endif -} - -CF_INLINE uint64_t CFSwapInt64HostToLittle(uint64_t arg) { -#if CF_USE_OSBYTEORDER_H - return OSSwapHostToLittleInt64(arg); -#elif __LITTLE_ENDIAN__ - return arg; -#else - return CFSwapInt64(arg); -#endif -} - -typedef struct {uint32_t v;} CFSwappedFloat32; -typedef struct {uint64_t v;} CFSwappedFloat64; - -CF_INLINE CFSwappedFloat32 CFConvertFloat32HostToSwapped(Float32 arg) { - union CFSwap { - Float32 v; - CFSwappedFloat32 sv; - } result; - result.v = arg; -#if __LITTLE_ENDIAN__ - result.sv.v = CFSwapInt32(result.sv.v); -#endif - return result.sv; -} - -CF_INLINE Float32 CFConvertFloat32SwappedToHost(CFSwappedFloat32 arg) { - union CFSwap { - Float32 v; - CFSwappedFloat32 sv; - } result; - result.sv = arg; -#if __LITTLE_ENDIAN__ - result.sv.v = CFSwapInt32(result.sv.v); -#endif - return result.v; -} - -CF_INLINE CFSwappedFloat64 CFConvertFloat64HostToSwapped(Float64 arg) { - union CFSwap { - Float64 v; - CFSwappedFloat64 sv; - } result; - result.v = arg; -#if __LITTLE_ENDIAN__ - result.sv.v = CFSwapInt64(result.sv.v); -#endif - return result.sv; -} - -CF_INLINE Float64 CFConvertFloat64SwappedToHost(CFSwappedFloat64 arg) { - union CFSwap { - Float64 v; - CFSwappedFloat64 sv; - } result; - result.sv = arg; -#if __LITTLE_ENDIAN__ - result.sv.v = CFSwapInt64(result.sv.v); -#endif - return result.v; -} - -CF_INLINE CFSwappedFloat32 CFConvertFloatHostToSwapped(float arg) { - union CFSwap { - float v; - CFSwappedFloat32 sv; - } result; - result.v = arg; -#if __LITTLE_ENDIAN__ - result.sv.v = CFSwapInt32(result.sv.v); -#endif - return result.sv; -} - -CF_INLINE float CFConvertFloatSwappedToHost(CFSwappedFloat32 arg) { - union CFSwap { - float v; - CFSwappedFloat32 sv; - } result; - result.sv = arg; -#if __LITTLE_ENDIAN__ - result.sv.v = CFSwapInt32(result.sv.v); -#endif - return result.v; -} - -CF_INLINE CFSwappedFloat64 CFConvertDoubleHostToSwapped(double arg) { - union CFSwap { - double v; - CFSwappedFloat64 sv; - } result; - result.v = arg; -#if __LITTLE_ENDIAN__ - result.sv.v = CFSwapInt64(result.sv.v); -#endif - return result.sv; -} - -CF_INLINE double CFConvertDoubleSwappedToHost(CFSwappedFloat64 arg) { - union CFSwap { - double v; - CFSwappedFloat64 sv; - } result; - result.sv = arg; -#if __LITTLE_ENDIAN__ - result.sv.v = CFSwapInt64(result.sv.v); -#endif - return result.v; -} - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFBYTEORDER__ */ - diff --git a/CFByteOrder.h b/CFByteOrder.h new file mode 120000 index 0000000..02f6cbe --- /dev/null +++ b/CFByteOrder.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFByteOrder.h \ No newline at end of file diff --git a/CFCalendar.h b/CFCalendar.h deleted file mode 100644 index ee684f9..0000000 --- a/CFCalendar.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFCalendar.h - Copyright (c) 2004-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFCALENDAR__) -#define __COREFOUNDATION_CFCALENDAR__ 1 - -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSCalendar) __CFCalendar * CFCalendarRef; - -CF_EXPORT -CFTypeID CFCalendarGetTypeID(void); - -CF_EXPORT -CFCalendarRef CFCalendarCopyCurrent(void); - -CF_EXPORT -CFCalendarRef CFCalendarCreateWithIdentifier(CFAllocatorRef allocator, CFStringRef identifier); - // Create a calendar. The identifiers are the kCF*Calendar - // constants in CFLocale.h. - -CF_EXPORT -CFStringRef CFCalendarGetIdentifier(CFCalendarRef calendar); - // Returns the calendar's identifier. - -CF_EXPORT -CFLocaleRef CFCalendarCopyLocale(CFCalendarRef calendar); - -CF_EXPORT -void CFCalendarSetLocale(CFCalendarRef calendar, CFLocaleRef locale); - -CF_EXPORT -CFTimeZoneRef CFCalendarCopyTimeZone(CFCalendarRef calendar); - -CF_EXPORT -void CFCalendarSetTimeZone(CFCalendarRef calendar, CFTimeZoneRef tz); - -CF_EXPORT -CFIndex CFCalendarGetFirstWeekday(CFCalendarRef calendar); - -CF_EXPORT -void CFCalendarSetFirstWeekday(CFCalendarRef calendar, CFIndex wkdy); - -CF_EXPORT -CFIndex CFCalendarGetMinimumDaysInFirstWeek(CFCalendarRef calendar); - -CF_EXPORT -void CFCalendarSetMinimumDaysInFirstWeek(CFCalendarRef calendar, CFIndex mwd); - - -typedef CF_OPTIONS(CFOptionFlags, CFCalendarUnit) { - kCFCalendarUnitEra = (1UL << 1), - kCFCalendarUnitYear = (1UL << 2), - kCFCalendarUnitMonth = (1UL << 3), - kCFCalendarUnitDay = (1UL << 4), - kCFCalendarUnitHour = (1UL << 5), - kCFCalendarUnitMinute = (1UL << 6), - kCFCalendarUnitSecond = (1UL << 7), - kCFCalendarUnitWeek CF_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0) = (1UL << 8), - kCFCalendarUnitWeekday = (1UL << 9), - kCFCalendarUnitWeekdayOrdinal = (1UL << 10), - kCFCalendarUnitQuarter CF_ENUM_AVAILABLE(10_6, 4_0) = (1UL << 11), - kCFCalendarUnitWeekOfMonth CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 12), - kCFCalendarUnitWeekOfYear CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 13), - kCFCalendarUnitYearForWeekOfYear CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 14), -}; - -CF_EXPORT -CFRange CFCalendarGetMinimumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit); - -CF_EXPORT -CFRange CFCalendarGetMaximumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit); - -CF_EXPORT -CFRange CFCalendarGetRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at); - -CF_EXPORT -CFIndex CFCalendarGetOrdinalityOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at); - -CF_EXPORT -Boolean CFCalendarGetTimeRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit, CFAbsoluteTime at, CFAbsoluteTime *startp, CFTimeInterval *tip) CF_AVAILABLE(10_5, 2_0); - -CF_EXPORT -Boolean CFCalendarComposeAbsoluteTime(CFCalendarRef calendar, /* out */ CFAbsoluteTime *at, const char *componentDesc, ...); - -CF_EXPORT -Boolean CFCalendarDecomposeAbsoluteTime(CFCalendarRef calendar, CFAbsoluteTime at, const char *componentDesc, ...); - - -enum { - kCFCalendarComponentsWrap = (1UL << 0) // option for adding -}; - -CF_EXPORT -Boolean CFCalendarAddComponents(CFCalendarRef calendar, /* inout */ CFAbsoluteTime *at, CFOptionFlags options, const char *componentDesc, ...); - -CF_EXPORT -Boolean CFCalendarGetComponentDifference(CFCalendarRef calendar, CFAbsoluteTime startingAT, CFAbsoluteTime resultAT, CFOptionFlags options, const char *componentDesc, ...); - - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFCALENDAR__ */ - diff --git a/CFCalendar.h b/CFCalendar.h new file mode 120000 index 0000000..4ade1e3 --- /dev/null +++ b/CFCalendar.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFCalendar.h \ No newline at end of file diff --git a/CFCharacterSet.h b/CFCharacterSet.h deleted file mode 100644 index 0614e30..0000000 --- a/CFCharacterSet.h +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFCharacterSet.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -/*! - @header CFCharacterSet - CFCharacterSet represents a set, or a bag, of Unicode characters. - The API consists of 3 groups: - 1) creation/manipulation of CFCharacterSet instances, - 2) query of a single Unicode character membership, - and 3) bitmap representation related (reading/writing). - Conceptually, CFCharacterSet is a 136K byte bitmap array of - which each bit represents a Unicode code point. It could - contain the Unicode characters in ISO 10646 Basic Multilingual - Plane (BMP) and characters in Plane 1 through Plane 16 - accessible via surrogate paris in the Unicode Transformation - Format, 16-bit encoding form (UTF-16). In other words, it can - store values from 0x00000 to 0x10FFFF in the Unicode - Transformation Format, 32-bit encoding form (UTF-32). However, - in general, how CFCharacterSet stores the information is an - implementation detail. Note even CFData used for the external - bitmap representation rarely has 136K byte. For detailed - discussion of the external bitmap representation, refer to the - comments for CFCharacterSetCreateWithBitmapRepresentation below. - Note that the existance of non-BMP characters in a character set - does not imply the membership of the corresponding surrogate - characters. For example, a character set with U+10000 does not - match with U+D800. -*/ - -#if !defined(__COREFOUNDATION_CFCHARACTERSET__) -#define __COREFOUNDATION_CFCHARACTERSET__ 1 - -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -/*! - @typedef CFCharacterSetRef - This is the type of a reference to immutable CFCharacterSets. -*/ -typedef const struct CF_BRIDGED_TYPE(NSCharacterSet) __CFCharacterSet * CFCharacterSetRef; - -/*! - @typedef CFMutableCharacterSetRef - This is the type of a reference to mutable CFMutableCharacterSets. -*/ -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableCharacterSet) __CFCharacterSet * CFMutableCharacterSetRef; - -/*! - @typedef CFCharacterSetPredefinedSet - Type of the predefined CFCharacterSet selector values. -*/ - -typedef CF_ENUM(CFIndex, CFCharacterSetPredefinedSet) { - kCFCharacterSetControl = 1, /* Control character set (Unicode General Category Cc and Cf) */ - kCFCharacterSetWhitespace, /* Whitespace character set (Unicode General Category Zs and U0009 CHARACTER TABULATION) */ - kCFCharacterSetWhitespaceAndNewline, /* Whitespace and Newline character set (Unicode General Category Z*, U000A ~ U000D, and U0085) */ - kCFCharacterSetDecimalDigit, /* Decimal digit character set */ - kCFCharacterSetLetter, /* Letter character set (Unicode General Category L* & M*) */ - kCFCharacterSetLowercaseLetter, /* Lowercase character set (Unicode General Category Ll) */ - kCFCharacterSetUppercaseLetter, /* Uppercase character set (Unicode General Category Lu and Lt) */ - kCFCharacterSetNonBase, /* Non-base character set (Unicode General Category M*) */ - kCFCharacterSetDecomposable, /* Canonically decomposable character set */ - kCFCharacterSetAlphaNumeric, /* Alpha Numeric character set (Unicode General Category L*, M*, & N*) */ - kCFCharacterSetPunctuation, /* Punctuation character set (Unicode General Category P*) */ - kCFCharacterSetCapitalizedLetter = 13, /* Titlecase character set (Unicode General Category Lt) */ - kCFCharacterSetSymbol = 14, /* Symbol character set (Unicode General Category S*) */ - kCFCharacterSetNewline CF_ENUM_AVAILABLE(10_5, 2_0) = 15, /* Newline character set (U000A ~ U000D, U0085, U2028, and U2029) */ - kCFCharacterSetIllegal = 12/* Illegal character set */ -}; - -/*! - @function CFCharacterSetGetTypeID - Returns the type identifier of all CFCharacterSet instances. -*/ -CF_EXPORT -CFTypeID CFCharacterSetGetTypeID(void); - -/*! - @function CFCharacterSetGetPredefined - Returns a predefined CFCharacterSet instance. - @param theSetIdentifier The CFCharacterSetPredefinedSet selector - which specifies the predefined character set. If the - value is not in CFCharacterSetPredefinedSet, the behavior - is undefined. - @result A reference to the predefined immutable CFCharacterSet. - This instance is owned by CF. -*/ -CF_EXPORT -CFCharacterSetRef CFCharacterSetGetPredefined(CFCharacterSetPredefinedSet theSetIdentifier); - -/*! - @function CFCharacterSetCreateWithCharactersInRange - Creates a new immutable character set with the values from the given range. - @param alloc The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param theRange The CFRange which should be used to specify the - Unicode range the character set is filled with. It - accepts the range in 32-bit in the UTF-32 format. The - valid character point range is from 0x00000 to 0x10FFFF. - If the range is outside of the valid Unicode character - point, the behavior is undefined. - @result A reference to the new immutable CFCharacterSet. -*/ -CF_EXPORT -CFCharacterSetRef CFCharacterSetCreateWithCharactersInRange(CFAllocatorRef alloc, CFRange theRange); - -/*! - @function CFCharacterSetCreateWithCharactersInString - Creates a new immutable character set with the values in the given string. - @param alloc The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param theString The CFString which should be used to specify - the Unicode characters the character set is filled with. - If this parameter is not a valid CFString, the behavior - is undefined. - @result A reference to the new immutable CFCharacterSet. -*/ -CF_EXPORT -CFCharacterSetRef CFCharacterSetCreateWithCharactersInString(CFAllocatorRef alloc, CFStringRef theString); - -/*! - @function CFCharacterSetCreateWithBitmapRepresentation - Creates a new immutable character set with the bitmap representtion in the given data. - @param alloc The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param theData The CFData which should be used to specify the - bitmap representation of the Unicode character points - the character set is filled with. The bitmap - representation could contain all the Unicode character - range starting from BMP to Plane 16. The first 8192 bytes - of the data represent the BMP range. The BMP range 8192 - bytes can be followed by zero to sixteen 8192 byte - bitmaps, each one with the plane index byte prepended. - For example, the bitmap representing the BMP and Plane 2 - has the size of 16385 bytes (8192 bytes for BMP, 1 byte - index + 8192 bytes bitmap for Plane 2). The plane index - byte, in this case, contains the integer value two. If - this parameter is not a valid CFData or it contains a - Plane index byte outside of the valid Plane range - (1 to 16), the behavior is undefined. - @result A reference to the new immutable CFCharacterSet. -*/ -CF_EXPORT -CFCharacterSetRef CFCharacterSetCreateWithBitmapRepresentation(CFAllocatorRef alloc, CFDataRef theData); - -/*! - @function CFCharacterSetCreateInvertedSet - Creates a new immutable character set that is the invert of the specified character set. - @param alloc The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param theSet The CFCharacterSet which is to be inverted. If this - parameter is not a valid CFCharacterSet, the behavior is - undefined. - @result A reference to the new immutable CFCharacterSet. -*/ -CF_EXPORT CFCharacterSetRef CFCharacterSetCreateInvertedSet(CFAllocatorRef alloc, CFCharacterSetRef theSet); - -/*! - @function CFCharacterSetIsSupersetOfSet - Reports whether or not the character set is a superset of the character set specified as the second parameter. - @param theSet The character set to be checked for the membership of theOtherSet. - If this parameter is not a valid CFCharacterSet, the behavior is undefined. - @param theOtherset The character set to be checked whether or not it is a subset of theSet. - If this parameter is not a valid CFCharacterSet, the behavior is undefined. -*/ -CF_EXPORT Boolean CFCharacterSetIsSupersetOfSet(CFCharacterSetRef theSet, CFCharacterSetRef theOtherset); - -/*! - @function CFCharacterSetHasMemberInPlane - Reports whether or not the character set contains at least one member character in the specified plane. - @param theSet The character set to be checked for the membership. If this - parameter is not a valid CFCharacterSet, the behavior is undefined. - @param thePlane The plane number to be checked for the membership. - The valid value range is from 0 to 16. If the value is outside of the valid - plane number range, the behavior is undefined. -*/ -CF_EXPORT Boolean CFCharacterSetHasMemberInPlane(CFCharacterSetRef theSet, CFIndex thePlane); - -/*! - @function CFCharacterSetCreateMutable - Creates a new empty mutable character set. - @param allocator The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @result A reference to the new mutable CFCharacterSet. -*/ -CF_EXPORT -CFMutableCharacterSetRef CFCharacterSetCreateMutable(CFAllocatorRef alloc); - -/*! - @function CFCharacterSetCreateCopy - Creates a new character set with the values from the given character set. This function tries to compact the backing store where applicable. - @param allocator The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param theSet The CFCharacterSet which is to be copied. If this - parameter is not a valid CFCharacterSet, the behavior is - undefined. - @result A reference to the new CFCharacterSet. -*/ -CF_EXPORT -CFCharacterSetRef CFCharacterSetCreateCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet); - -/*! - @function CFCharacterSetCreateMutableCopy - Creates a new mutable character set with the values from the given character set. - @param allocator The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param theSet The CFCharacterSet which is to be copied. If this - parameter is not a valid CFCharacterSet, the behavior is - undefined. - @result A reference to the new mutable CFCharacterSet. -*/ -CF_EXPORT -CFMutableCharacterSetRef CFCharacterSetCreateMutableCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet); - -/*! - @function CFCharacterSetIsCharacterMember - Reports whether or not the Unicode character is in the character set. - @param theSet The character set to be searched. If this parameter - is not a valid CFCharacterSet, the behavior is undefined. - @param theChar The Unicode character for which to test against the - character set. Note that this function takes 16-bit Unicode - character value; hence, it does not support access to the - non-BMP planes. - @result true, if the value is in the character set, otherwise false. -*/ -CF_EXPORT -Boolean CFCharacterSetIsCharacterMember(CFCharacterSetRef theSet, UniChar theChar); - -/*! - @function CFCharacterSetIsLongCharacterMember - Reports whether or not the UTF-32 character is in the character set. - @param theSet The character set to be searched. If this parameter - is not a valid CFCharacterSet, the behavior is undefined. - @param theChar The UTF-32 character for which to test against the - character set. - @result true, if the value is in the character set, otherwise false. -*/ -CF_EXPORT Boolean CFCharacterSetIsLongCharacterMember(CFCharacterSetRef theSet, UTF32Char theChar); - -/*! - @function CFCharacterSetCreateBitmapRepresentation - Creates a new immutable data with the bitmap representation from the given character set. - @param allocator The CFAllocator which should be used to allocate - memory for the array and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param theSet The CFCharacterSet which is to be used create the - bitmap representation from. Refer to the comments for - CFCharacterSetCreateWithBitmapRepresentation for the - detailed discussion of the bitmap representation format. - If this parameter is not a valid CFCharacterSet, the - behavior is undefined. - @result A reference to the new immutable CFData. -*/ -CF_EXPORT -CFDataRef CFCharacterSetCreateBitmapRepresentation(CFAllocatorRef alloc, CFCharacterSetRef theSet); - -/*! - @function CFCharacterSetAddCharactersInRange - Adds the given range to the charaacter set. - @param theSet The character set to which the range is to be added. - If this parameter is not a valid mutable CFCharacterSet, - the behavior is undefined. - @param theRange The range to add to the character set. It accepts - the range in 32-bit in the UTF-32 format. The valid - character point range is from 0x00000 to 0x10FFFF. If the - range is outside of the valid Unicode character point, - the behavior is undefined. -*/ -CF_EXPORT -void CFCharacterSetAddCharactersInRange(CFMutableCharacterSetRef theSet, CFRange theRange); - -/*! - @function CFCharacterSetRemoveCharactersInRange - Removes the given range from the charaacter set. - @param theSet The character set from which the range is to be - removed. If this parameter is not a valid mutable - CFCharacterSet, the behavior is undefined. - @param theRange The range to remove from the character set. - It accepts the range in 32-bit in the UTF-32 format. - The valid character point range is from 0x00000 to 0x10FFFF. - If the range is outside of the valid Unicode character point, - the behavior is undefined. -*/ -CF_EXPORT -void CFCharacterSetRemoveCharactersInRange(CFMutableCharacterSetRef theSet, CFRange theRange); - -/*! - @function CFCharacterSetAddCharactersInString - Adds the characters in the given string to the charaacter set. - @param theSet The character set to which the characters in the - string are to be added. If this parameter is not a - valid mutable CFCharacterSet, the behavior is undefined. - @param theString The string to add to the character set. - If this parameter is not a valid CFString, the behavior - is undefined. -*/ -CF_EXPORT -void CFCharacterSetAddCharactersInString(CFMutableCharacterSetRef theSet, CFStringRef theString); - -/*! - @function CFCharacterSetRemoveCharactersInString - Removes the characters in the given string from the charaacter set. - @param theSet The character set from which the characters in the - string are to be remove. If this parameter is not a - valid mutable CFCharacterSet, the behavior is undefined. - @param theString The string to remove from the character set. - If this parameter is not a valid CFString, the behavior - is undefined. -*/ -CF_EXPORT -void CFCharacterSetRemoveCharactersInString(CFMutableCharacterSetRef theSet, CFStringRef theString); - -/*! - @function CFCharacterSetUnion - Forms the union with the given character set. - @param theSet The destination character set into which the - union of the two character sets is stored. If this - parameter is not a valid mutable CFCharacterSet, the - behavior is undefined. - @param theOtherSet The character set with which the union is - formed. If this parameter is not a valid CFCharacterSet, - the behavior is undefined. -*/ -CF_EXPORT -void CFCharacterSetUnion(CFMutableCharacterSetRef theSet, CFCharacterSetRef theOtherSet); - -/*! - @function CFCharacterSetIntersect - Forms the intersection with the given character set. - @param theSet The destination character set into which the - intersection of the two character sets is stored. - If this parameter is not a valid mutable CFCharacterSet, - the behavior is undefined. - @param theOtherSet The character set with which the intersection - is formed. If this parameter is not a valid CFCharacterSet, - the behavior is undefined. -*/ -CF_EXPORT -void CFCharacterSetIntersect(CFMutableCharacterSetRef theSet, CFCharacterSetRef theOtherSet); - -/*! - @function CFCharacterSetInvert - Inverts the content of the given character set. - @param theSet The character set to be inverted. - If this parameter is not a valid mutable CFCharacterSet, - the behavior is undefined. -*/ -CF_EXPORT -void CFCharacterSetInvert(CFMutableCharacterSetRef theSet); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFCHARACTERSET__ */ - diff --git a/CFCharacterSet.h b/CFCharacterSet.h new file mode 120000 index 0000000..70b4c53 --- /dev/null +++ b/CFCharacterSet.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFCharacterSet.h \ No newline at end of file diff --git a/CFCharacterSetPriv.h b/CFCharacterSetPriv.h deleted file mode 100644 index 0758b90..0000000 --- a/CFCharacterSetPriv.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFCharacterSetPriv.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFCHARACTERSETPRIV__) -#define __COREFOUNDATION_CFCHARACTERSETPRIV__ 1 - -#include - -CF_EXTERN_C_BEGIN - -/*! - @function CFCharacterSetIsSurrogateHighCharacter - Reports whether or not the character is a high surrogate. - @param character The character to be checked. - @result true, if character is a high surrogate, otherwise false. -*/ -CF_INLINE Boolean CFCharacterSetIsSurrogateHighCharacter(UniChar character) { - return ((character >= 0xD800UL) && (character <= 0xDBFFUL) ? true : false); -} - -/*! - @function CFCharacterSetIsSurrogateLowCharacter - Reports whether or not the character is a low surrogate. - @param character The character to be checked. - @result true, if character is a low surrogate, otherwise false. -*/ -CF_INLINE Boolean CFCharacterSetIsSurrogateLowCharacter(UniChar character) { - return ((character >= 0xDC00UL) && (character <= 0xDFFFUL) ? true : false); -} - -/*! - @function CFCharacterSetGetLongCharacterForSurrogatePair - Returns the UTF-32 value corresponding to the surrogate pair passed in. - @param surrogateHigh The high surrogate character. If this parameter - is not a valid high surrogate character, the behavior is undefined. - @param surrogateLow The low surrogate character. If this parameter - is not a valid low surrogate character, the behavior is undefined. - @result The UTF-32 value for the surrogate pair. -*/ -CF_INLINE UTF32Char CFCharacterSetGetLongCharacterForSurrogatePair(UniChar surrogateHigh, UniChar surrogateLow) { - return (UTF32Char)(((surrogateHigh - 0xD800UL) << 10) + (surrogateLow - 0xDC00UL) + 0x0010000UL); -} - -/* Check to see if the character represented by the surrogate pair surrogateHigh & surrogateLow is in the chraracter set */ -CF_EXPORT Boolean CFCharacterSetIsSurrogatePairMember(CFCharacterSetRef theSet, UniChar surrogateHigh, UniChar surrogateLow) ; - -/* Keyed-coding support -*/ -typedef CF_ENUM(CFIndex, CFCharacterSetKeyedCodingType) { - kCFCharacterSetKeyedCodingTypeBitmap = 1, - kCFCharacterSetKeyedCodingTypeBuiltin = 2, - kCFCharacterSetKeyedCodingTypeRange = 3, - kCFCharacterSetKeyedCodingTypeString = 4, - kCFCharacterSetKeyedCodingTypeBuiltinAndBitmap = 5 -}; - -CF_EXPORT CFCharacterSetKeyedCodingType _CFCharacterSetGetKeyedCodingType(CFCharacterSetRef cset); -CF_EXPORT CFCharacterSetPredefinedSet _CFCharacterSetGetKeyedCodingBuiltinType(CFCharacterSetRef cset); -CF_EXPORT CFRange _CFCharacterSetGetKeyedCodingRange(CFCharacterSetRef cset); -CF_EXPORT CFStringRef _CFCharacterSetCreateKeyedCodingString(CFCharacterSetRef cset); -CF_EXPORT bool _CFCharacterSetIsInverted(CFCharacterSetRef cset); -CF_EXPORT void _CFCharacterSetSetIsInverted(CFCharacterSetRef cset, bool flag); - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFCHARACTERSETPRIV__ */ - diff --git a/CFCharacterSetPriv.h b/CFCharacterSetPriv.h new file mode 120000 index 0000000..34fecfe --- /dev/null +++ b/CFCharacterSetPriv.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFCharacterSetPriv.h \ No newline at end of file diff --git a/CFData.h b/CFData.h deleted file mode 100644 index ee436ca..0000000 --- a/CFData.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFData.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFDATA__) -#define __COREFOUNDATION_CFDATA__ 1 - -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef const struct CF_BRIDGED_TYPE(NSData) __CFData * CFDataRef; -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableData) __CFData * CFMutableDataRef; - -CF_EXPORT -CFTypeID CFDataGetTypeID(void); - -CF_EXPORT -CFDataRef CFDataCreate(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex length); - -CF_EXPORT -CFDataRef CFDataCreateWithBytesNoCopy(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex length, CFAllocatorRef bytesDeallocator); - /* Pass kCFAllocatorNull as bytesDeallocator to assure the bytes aren't freed */ - -CF_EXPORT -CFDataRef CFDataCreateCopy(CFAllocatorRef allocator, CFDataRef theData); - -CF_EXPORT -CFMutableDataRef CFDataCreateMutable(CFAllocatorRef allocator, CFIndex capacity); - -CF_EXPORT -CFMutableDataRef CFDataCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDataRef theData); - -CF_EXPORT -CFIndex CFDataGetLength(CFDataRef theData); - -CF_EXPORT -const UInt8 *CFDataGetBytePtr(CFDataRef theData); - -CF_EXPORT -UInt8 *CFDataGetMutableBytePtr(CFMutableDataRef theData); - -CF_EXPORT -void CFDataGetBytes(CFDataRef theData, CFRange range, UInt8 *buffer); - -CF_EXPORT -void CFDataSetLength(CFMutableDataRef theData, CFIndex length); - -CF_EXPORT -void CFDataIncreaseLength(CFMutableDataRef theData, CFIndex extraLength); - -CF_EXPORT -void CFDataAppendBytes(CFMutableDataRef theData, const UInt8 *bytes, CFIndex length); - -CF_EXPORT -void CFDataReplaceBytes(CFMutableDataRef theData, CFRange range, const UInt8 *newBytes, CFIndex newLength); - -CF_EXPORT -void CFDataDeleteBytes(CFMutableDataRef theData, CFRange range); - -typedef CF_OPTIONS(CFOptionFlags, CFDataSearchFlags) { - kCFDataSearchBackwards = 1UL << 0, - kCFDataSearchAnchored = 1UL << 1 -} CF_ENUM_AVAILABLE(10_6, 4_0); - -CF_EXPORT -CFRange CFDataFind(CFDataRef theData, CFDataRef dataToFind, CFRange searchRange, CFDataSearchFlags compareOptions) CF_AVAILABLE(10_6, 4_0); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFDATA__ */ - diff --git a/CFData.h b/CFData.h new file mode 120000 index 0000000..50d5f58 --- /dev/null +++ b/CFData.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFData.h \ No newline at end of file diff --git a/CFDate.h b/CFDate.h deleted file mode 100644 index 98767f9..0000000 --- a/CFDate.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFDate.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFDATE__) -#define __COREFOUNDATION_CFDATE__ 1 - -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef double CFTimeInterval; -typedef CFTimeInterval CFAbsoluteTime; -/* absolute time is the time interval since the reference date */ -/* the reference date (epoch) is 00:00:00 1 January 2001. */ - -CF_EXPORT -CFAbsoluteTime CFAbsoluteTimeGetCurrent(void); - -CF_EXPORT -const CFTimeInterval kCFAbsoluteTimeIntervalSince1970; -CF_EXPORT -const CFTimeInterval kCFAbsoluteTimeIntervalSince1904; - -typedef const struct CF_BRIDGED_TYPE(NSDate) __CFDate * CFDateRef; - -CF_EXPORT -CFTypeID CFDateGetTypeID(void); - -CF_EXPORT -CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at); - -CF_EXPORT -CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate); - -CF_EXPORT -CFTimeInterval CFDateGetTimeIntervalSinceDate(CFDateRef theDate, CFDateRef otherDate); - -CF_EXPORT -CFComparisonResult CFDateCompare(CFDateRef theDate, CFDateRef otherDate, void *context); - -CF_IMPLICIT_BRIDGING_DISABLED - -typedef const struct CF_BRIDGED_TYPE(NSTimeZone) __CFTimeZone * CFTimeZoneRef; - - -#if !defined(CF_CALENDAR_ENUM_DEPRECATED) -#define CF_CALENDAR_ENUM_DEPRECATED(A, B, C, D, ...) CF_ENUM_DEPRECATED(A, B, C, D, __VA_ARGS__) -#define CF_CALENDAR_DEPRECATED(A, B, C, D, ...) CF_DEPRECATED(A, B, C, D, __VA_ARGS__) -#endif - -typedef struct { - SInt32 year; - SInt8 month; - SInt8 day; - SInt8 hour; - SInt8 minute; - double second; -} CFGregorianDate CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); - -typedef struct { - SInt32 years; - SInt32 months; - SInt32 days; - SInt32 hours; - SInt32 minutes; - double seconds; -} CFGregorianUnits CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); - -typedef CF_OPTIONS(CFOptionFlags, CFGregorianUnitFlags) { - kCFGregorianUnitsYears CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 0), - kCFGregorianUnitsMonths CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 1), - kCFGregorianUnitsDays CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 2), - kCFGregorianUnitsHours CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 3), - kCFGregorianUnitsMinutes CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 4), - kCFGregorianUnitsSeconds CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 5), - kCFGregorianAllUnits CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = 0x00FFFFFF -}; - -CF_EXPORT -Boolean CFGregorianDateIsValid(CFGregorianDate gdate, CFOptionFlags unitFlags) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); - -CF_EXPORT -CFAbsoluteTime CFGregorianDateGetAbsoluteTime(CFGregorianDate gdate, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); - -CF_EXPORT -CFGregorianDate CFAbsoluteTimeGetGregorianDate(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); - -CF_EXPORT -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"); - -CF_EXPORT -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"); - -CF_EXPORT -SInt32 CFAbsoluteTimeGetDayOfWeek(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); - -CF_EXPORT -SInt32 CFAbsoluteTimeGetDayOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); - -CF_EXPORT -SInt32 CFAbsoluteTimeGetWeekOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFDATE__ */ - diff --git a/CFDate.h b/CFDate.h new file mode 120000 index 0000000..f05d1fd --- /dev/null +++ b/CFDate.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFDate.h \ No newline at end of file diff --git a/CFDateFormatter.h b/CFDateFormatter.h deleted file mode 100644 index 892aee6..0000000 --- a/CFDateFormatter.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFDateFormatter.h - Copyright (c) 2003-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFDATEFORMATTER__) -#define __COREFOUNDATION_CFDATEFORMATTER__ 1 - -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct __CFDateFormatter *CFDateFormatterRef; - -// CFDateFormatters are not thread-safe. Do not use one from multiple threads! - -CF_EXPORT -CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator, CFStringRef tmplate, CFOptionFlags options, CFLocaleRef locale) CF_AVAILABLE(10_6, 4_0); - // no options defined, pass 0 for now - -CF_EXPORT -CFTypeID CFDateFormatterGetTypeID(void); - -typedef CF_ENUM(CFIndex, CFDateFormatterStyle) { // date and time format styles - kCFDateFormatterNoStyle = 0, - kCFDateFormatterShortStyle = 1, - kCFDateFormatterMediumStyle = 2, - kCFDateFormatterLongStyle = 3, - kCFDateFormatterFullStyle = 4 -}; - -// The exact formatted result for these date and time styles depends on the -// locale, but generally: -// Short is completely numeric, such as "12/13/52" or "3:30pm" -// Medium is longer, such as "Jan 12, 1952" -// Long is longer, such as "January 12, 1952" or "3:30:32pm" -// Full is pretty complete; e.g. "Tuesday, April 12, 1952 AD" or "3:30:42pm PST" -// The specifications though are left fuzzy, in part simply because a user's -// preference choices may affect the output, and also the results may change -// from one OS release to another. To produce an exactly formatted date you -// should not rely on styles and localization, but set the format string and -// use nothing but numbers. - -CF_EXPORT -CFDateFormatterRef CFDateFormatterCreate(CFAllocatorRef allocator, CFLocaleRef locale, CFDateFormatterStyle dateStyle, CFDateFormatterStyle timeStyle); - // Returns a CFDateFormatter, localized to the given locale, which - // will format dates to the given date and time styles. - -CF_EXPORT -CFLocaleRef CFDateFormatterGetLocale(CFDateFormatterRef formatter); - -CF_EXPORT -CFDateFormatterStyle CFDateFormatterGetDateStyle(CFDateFormatterRef formatter); - -CF_EXPORT -CFDateFormatterStyle CFDateFormatterGetTimeStyle(CFDateFormatterRef formatter); - // Get the properties with which the date formatter was created. - -CF_EXPORT -CFStringRef CFDateFormatterGetFormat(CFDateFormatterRef formatter); - -CF_EXPORT -void CFDateFormatterSetFormat(CFDateFormatterRef formatter, CFStringRef formatString); - // Set the format description string of the date formatter. This - // overrides the style settings. The format of the format string - // is as defined by the ICU library. The date formatter starts with a - // default format string defined by the style arguments with - // which it was created. - - -CF_EXPORT -CFStringRef CFDateFormatterCreateStringWithDate(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFDateRef date); - -CF_EXPORT -CFStringRef CFDateFormatterCreateStringWithAbsoluteTime(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFAbsoluteTime at); - // Create a string representation of the given date or CFAbsoluteTime - // using the current state of the date formatter. - - -CF_EXPORT -CFDateRef CFDateFormatterCreateDateFromString(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFStringRef string, CFRange *rangep); - -CF_EXPORT -Boolean CFDateFormatterGetAbsoluteTimeFromString(CFDateFormatterRef formatter, CFStringRef string, CFRange *rangep, CFAbsoluteTime *atp); - // Parse a string representation of a date using the current state - // of the date formatter. The range parameter specifies the range - // of the string in which the parsing should occur in input, and on - // output indicates the extent that was used; this parameter can - // be NULL, in which case the whole string may be used. The - // return value indicates whether some date was computed and - // (if atp is not NULL) stored at the location specified by atp. - - -CF_EXPORT -void CFDateFormatterSetProperty(CFDateFormatterRef formatter, CFStringRef key, CFTypeRef value); - -CF_EXPORT -CFTypeRef CFDateFormatterCopyProperty(CFDateFormatterRef formatter, CFStringRef key); - // Set and get various properties of the date formatter, the set of - // which may be expanded in the future. - -CF_EXPORT const CFStringRef kCFDateFormatterIsLenient; // CFBoolean -CF_EXPORT const CFStringRef kCFDateFormatterTimeZone; // CFTimeZone -CF_EXPORT const CFStringRef kCFDateFormatterCalendarName; // CFString -CF_EXPORT const CFStringRef kCFDateFormatterDefaultFormat; // CFString -CF_EXPORT const CFStringRef kCFDateFormatterTwoDigitStartDate; // CFDate -CF_EXPORT const CFStringRef kCFDateFormatterDefaultDate; // CFDate -CF_EXPORT const CFStringRef kCFDateFormatterCalendar; // CFCalendar -CF_EXPORT const CFStringRef kCFDateFormatterEraSymbols; // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterMonthSymbols; // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterShortMonthSymbols; // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterWeekdaySymbols; // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterShortWeekdaySymbols; // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterAMSymbol; // CFString -CF_EXPORT const CFStringRef kCFDateFormatterPMSymbol; // CFString -CF_EXPORT const CFStringRef kCFDateFormatterLongEraSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterVeryShortMonthSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterStandaloneMonthSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneMonthSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterVeryShortStandaloneMonthSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterVeryShortWeekdaySymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterStandaloneWeekdaySymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneWeekdaySymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterVeryShortStandaloneWeekdaySymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterQuarterSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterShortQuarterSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterStandaloneQuarterSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneQuarterSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString -CF_EXPORT const CFStringRef kCFDateFormatterGregorianStartDate CF_AVAILABLE(10_5, 2_0); // CFDate -CF_EXPORT const CFStringRef kCFDateFormatterDoesRelativeDateFormattingKey CF_AVAILABLE(10_6, 4_0); // CFBoolean - -// See CFLocale.h for these calendar constants: -// const CFStringRef kCFGregorianCalendar; -// const CFStringRef kCFBuddhistCalendar; -// const CFStringRef kCFJapaneseCalendar; -// const CFStringRef kCFIslamicCalendar; -// const CFStringRef kCFIslamicCivilCalendar; -// const CFStringRef kCFHebrewCalendar; -// const CFStringRef kCFChineseCalendar; -// const CFStringRef kCFRepublicOfChinaCalendar; -// const CFStringRef kCFPersianCalendar; -// const CFStringRef kCFIndianCalendar; -// const CFStringRef kCFISO8601Calendar; - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFDATEFORMATTER__ */ - diff --git a/CFDateFormatter.h b/CFDateFormatter.h new file mode 120000 index 0000000..c49c157 --- /dev/null +++ b/CFDateFormatter.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFDateFormatter.h \ No newline at end of file diff --git a/CFDictionary.h b/CFDictionary.h deleted file mode 100644 index b5c6194..0000000 --- a/CFDictionary.h +++ /dev/null @@ -1,692 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFDictionary.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -/*! - @header CFDictionary - CFDictionary implements a container which pairs pointer-sized keys - with pointer-sized values. Values are accessed via arbitrary - user-defined keys. A CFDictionary differs from a CFArray in that - the key used to access a particular value in the dictionary remains - the same as values are added to or removed from the dictionary, - unless a value associated with its particular key is replaced or - removed. In a CFArray, the key (or index) used to retrieve a - particular value can change over time as values are added to or - deleted from the array. Also unlike an array, there is no ordering - among values in a dictionary. To enable later retrieval of a value, - the key of the key-value pair should be constant (or treated as - constant); if the key changes after being used to put a value in - the dictionary, the value may not be retrievable. The keys of a - dictionary form a set; that is, no two keys which are equal to - one another are present in the dictionary at any time. - - Dictionaries come in two flavors, immutable, which cannot have - values added to them or removed from them after the dictionary is - created, and mutable, to which you can add values or from which - remove values. Mutable dictionaries can have an unlimited number - of values (or rather, limited only by constraints external to - CFDictionary, like the amount of available memory). - - As with all CoreFoundation collection types, dictionaries maintain - hard references on the values you put in them, but the retaining and - releasing functions are user-defined callbacks that can actually do - whatever the user wants (for example, nothing). - - Although a particular implementation of CFDictionary may not use - hashing and a hash table for storage of the values, the keys have - a hash-code generating function defined for them, and a function - to test for equality of two keys. These two functions together - must maintain the invariant that if equal(X, Y), then hash(X) == - hash(Y). Note that the converse will not generally be true (but - the contrapositive, if hash(X) != hash(Y), then !equal(X, Y), - will be as required by Boolean logic). If the hash() and equal() - key callbacks are NULL, the key is used as a pointer-sized integer, - and pointer equality is used. Care should be taken to provide a - hash() callback which will compute sufficiently dispersed hash - codes for the key set for best performance. - - Computational Complexity - The access time for a value in the dictionary is guaranteed to be at - worst O(N) for any implementation, current and future, but will - often be O(1) (constant time). Insertion or deletion operations - will typically be constant time as well, but are O(N*N) in the - worst case in some implementations. Access of values through a key - is faster than accessing values directly (if there are any such - operations). Dictionaries will tend to use significantly more memory - than a array with the same number of values. -*/ - -#if !defined(__COREFOUNDATION_CFDICTIONARY__) -#define __COREFOUNDATION_CFDICTIONARY__ 1 - -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -/*! - @typedef CFDictionaryKeyCallBacks - Structure containing the callbacks for keys of a CFDictionary. - @field version The version number of the structure type being passed - in as a parameter to the CFDictionary creation functions. - This structure is version 0. - @field retain The callback used to add a retain for the dictionary - on keys as they are used to put values into the dictionary. - This callback returns the value to use as the key in the - dictionary, which is usually the value parameter passed to - this callback, but may be a different value if a different - value should be used as the key. The dictionary's allocator - is passed as the first argument. - @field release The callback used to remove a retain previously added - for the dictionary from keys as their values are removed from - the dictionary. The dictionary's allocator is passed as the - first argument. - @field copyDescription The callback used to create a descriptive - string representation of each key in the dictionary. This - is used by the CFCopyDescription() function. - @field equal The callback used to compare keys in the dictionary for - equality. - @field hash The callback used to compute a hash code for keys as they - are used to access, add, or remove values in the dictionary. -*/ -typedef const void * (*CFDictionaryRetainCallBack)(CFAllocatorRef allocator, const void *value); -typedef void (*CFDictionaryReleaseCallBack)(CFAllocatorRef allocator, const void *value); -typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack)(const void *value); -typedef Boolean (*CFDictionaryEqualCallBack)(const void *value1, const void *value2); -typedef CFHashCode (*CFDictionaryHashCallBack)(const void *value); -typedef struct { - CFIndex version; - CFDictionaryRetainCallBack retain; - CFDictionaryReleaseCallBack release; - CFDictionaryCopyDescriptionCallBack copyDescription; - CFDictionaryEqualCallBack equal; - CFDictionaryHashCallBack hash; -} CFDictionaryKeyCallBacks; - -/*! - @constant kCFTypeDictionaryKeyCallBacks - Predefined CFDictionaryKeyCallBacks structure containing a - set of callbacks appropriate for use when the keys of a - CFDictionary are all CFTypes. -*/ -CF_EXPORT -const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; - -/*! - @constant kCFCopyStringDictionaryKeyCallBacks - Predefined CFDictionaryKeyCallBacks structure containing a - set of callbacks appropriate for use when the keys of a - CFDictionary are all CFStrings, which may be mutable and - need to be copied in order to serve as constant keys for - the values in the dictionary. -*/ -CF_EXPORT -const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks; - -/*! - @typedef CFDictionaryValueCallBacks - Structure containing the callbacks for values of a CFDictionary. - @field version The version number of the structure type being passed - in as a parameter to the CFDictionary creation functions. - This structure is version 0. - @field retain The callback used to add a retain for the dictionary - on values as they are put into the dictionary. - This callback returns the value to use as the value in the - dictionary, which is usually the value parameter passed to - this callback, but may be a different value if a different - value should be added to the dictionary. The dictionary's - allocator is passed as the first argument. - @field release The callback used to remove a retain previously added - for the dictionary from values as they are removed from - the dictionary. The dictionary's allocator is passed as the - first argument. - @field copyDescription The callback used to create a descriptive - string representation of each value in the dictionary. This - is used by the CFCopyDescription() function. - @field equal The callback used to compare values in the dictionary for - equality in some operations. -*/ -typedef struct { - CFIndex version; - CFDictionaryRetainCallBack retain; - CFDictionaryReleaseCallBack release; - CFDictionaryCopyDescriptionCallBack copyDescription; - CFDictionaryEqualCallBack equal; -} CFDictionaryValueCallBacks; - -/*! - @constant kCFTypeDictionaryValueCallBacks - Predefined CFDictionaryValueCallBacks structure containing a set - of callbacks appropriate for use when the values in a CFDictionary - are all CFTypes. -*/ -CF_EXPORT -const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; - -/*! - @typedef CFDictionaryApplierFunction - Type of the callback function used by the apply functions of - CFDictionarys. - @param key The current key for the value. - @param value The current value from the dictionary. - @param context The user-defined context parameter given to the apply - function. -*/ -typedef void (*CFDictionaryApplierFunction)(const void *key, const void *value, void *context); - -/*! - @typedef CFDictionaryRef - This is the type of a reference to immutable CFDictionarys. -*/ -typedef const struct CF_BRIDGED_TYPE(NSDictionary) __CFDictionary * CFDictionaryRef; - -/*! - @typedef CFMutableDictionaryRef - This is the type of a reference to mutable CFDictionarys. -*/ -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableDictionary) __CFDictionary * CFMutableDictionaryRef; - -/*! - @function CFDictionaryGetTypeID - Returns the type identifier of all CFDictionary instances. -*/ -CF_EXPORT -CFTypeID CFDictionaryGetTypeID(void); - -/*! - @function CFDictionaryCreate - Creates a new immutable dictionary with the given values. - @param allocator The CFAllocator which should be used to allocate - memory for the dictionary and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param keys A C array of the pointer-sized keys to be used for - the parallel C array of values to be put into the dictionary. - This parameter may be NULL if the numValues parameter is 0. - This C array is not changed or freed by this function. If - this parameter is not a valid pointer to a C array of at - least numValues pointers, the behavior is undefined. - @param values A C array of the pointer-sized values to be in the - dictionary. This parameter may be NULL if the numValues - parameter is 0. This C array is not changed or freed by - this function. If this parameter is not a valid pointer to - a C array of at least numValues pointers, the behavior is - undefined. - @param numValues The number of values to copy from the keys and - values C arrays into the CFDictionary. This number will be - the count of the dictionary. If this parameter is - negative, or greater than the number of values actually - in the keys or values C arrays, the behavior is undefined. - @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure - initialized with the callbacks for the dictionary to use on - each key in the dictionary. The retain callback will be used - within this function, for example, to retain all of the new - keys from the keys C array. A copy of the contents of the - callbacks structure is made, so that a pointer to a structure - on the stack can be passed in, or can be reused for multiple - dictionary creations. If the version field of this - callbacks structure is not one of the defined ones for - CFDictionary, the behavior is undefined. The retain field may - be NULL, in which case the CFDictionary will do nothing to add - a retain to the keys of the contained values. The release field - may be NULL, in which case the CFDictionary will do nothing - to remove the dictionary's retain (if any) on the keys when the - dictionary is destroyed or a key-value pair is removed. If the - copyDescription field is NULL, the dictionary will create a - simple description for a key. If the equal field is NULL, the - dictionary will use pointer equality to test for equality of - keys. If the hash field is NULL, a key will be converted from - a pointer to an integer to compute the hash code. This callbacks - parameter itself may be NULL, which is treated as if a valid - structure of version 0 with all fields NULL had been passed in. - Otherwise, if any of the fields are not valid pointers to - functions of the correct type, or this parameter is not a - valid pointer to a CFDictionaryKeyCallBacks callbacks structure, - the behavior is undefined. If any of the keys put into the - dictionary is not one understood by one of the callback functions - the behavior when that callback function is used is undefined. - @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure - initialized with the callbacks for the dictionary to use on - each value in the dictionary. The retain callback will be used - within this function, for example, to retain all of the new - values from the values C array. A copy of the contents of the - callbacks structure is made, so that a pointer to a structure - on the stack can be passed in, or can be reused for multiple - dictionary creations. If the version field of this callbacks - structure is not one of the defined ones for CFDictionary, the - behavior is undefined. The retain field may be NULL, in which - case the CFDictionary will do nothing to add a retain to values - as they are put into the dictionary. The release field may be - NULL, in which case the CFDictionary will do nothing to remove - the dictionary's retain (if any) on the values when the - dictionary is destroyed or a key-value pair is removed. If the - copyDescription field is NULL, the dictionary will create a - simple description for a value. If the equal field is NULL, the - dictionary will use pointer equality to test for equality of - values. This callbacks parameter itself may be NULL, which is - treated as if a valid structure of version 0 with all fields - NULL had been passed in. Otherwise, - if any of the fields are not valid pointers to functions - of the correct type, or this parameter is not a valid - pointer to a CFDictionaryValueCallBacks callbacks structure, - the behavior is undefined. If any of the values put into the - dictionary is not one understood by one of the callback functions - the behavior when that callback function is used is undefined. - @result A reference to the new immutable CFDictionary. -*/ -CF_EXPORT -CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks); - -/*! - @function CFDictionaryCreateCopy - Creates a new immutable dictionary with the key-value pairs from - the given dictionary. - @param allocator The CFAllocator which should be used to allocate - memory for the dictionary and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param theDict The dictionary which is to be copied. The keys and values - from the dictionary are copied as pointers into the new - dictionary (that is, the values themselves are copied, not - that which the values point to, if anything). However, the - keys and values are also retained by the new dictionary using - the retain function of the original dictionary. - The count of the new dictionary will be the same as the - given dictionary. The new dictionary uses the same callbacks - as the dictionary to be copied. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @result A reference to the new immutable CFDictionary. -*/ -CF_EXPORT -CFDictionaryRef CFDictionaryCreateCopy(CFAllocatorRef allocator, CFDictionaryRef theDict); - -/*! - @function CFDictionaryCreateMutable - Creates a new mutable dictionary. - @param allocator The CFAllocator which should be used to allocate - memory for the dictionary and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param capacity A hint about the number of values that will be held - by the CFDictionary. Pass 0 for no hint. The implementation may - ignore this hint, or may use it to optimize various - operations. A dictionary's actual capacity is only limited by - address space and available memory constraints). If this - parameter is negative, the behavior is undefined. - @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure - initialized with the callbacks for the dictionary to use on - each key in the dictionary. A copy of the contents of the - callbacks structure is made, so that a pointer to a structure - on the stack can be passed in, or can be reused for multiple - dictionary creations. If the version field of this - callbacks structure is not one of the defined ones for - CFDictionary, the behavior is undefined. The retain field may - be NULL, in which case the CFDictionary will do nothing to add - a retain to the keys of the contained values. The release field - may be NULL, in which case the CFDictionary will do nothing - to remove the dictionary's retain (if any) on the keys when the - dictionary is destroyed or a key-value pair is removed. If the - copyDescription field is NULL, the dictionary will create a - simple description for a key. If the equal field is NULL, the - dictionary will use pointer equality to test for equality of - keys. If the hash field is NULL, a key will be converted from - a pointer to an integer to compute the hash code. This callbacks - parameter itself may be NULL, which is treated as if a valid - structure of version 0 with all fields NULL had been passed in. - Otherwise, if any of the fields are not valid pointers to - functions of the correct type, or this parameter is not a - valid pointer to a CFDictionaryKeyCallBacks callbacks structure, - the behavior is undefined. If any of the keys put into the - dictionary is not one understood by one of the callback functions - the behavior when that callback function is used is undefined. - @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure - initialized with the callbacks for the dictionary to use on - each value in the dictionary. The retain callback will be used - within this function, for example, to retain all of the new - values from the values C array. A copy of the contents of the - callbacks structure is made, so that a pointer to a structure - on the stack can be passed in, or can be reused for multiple - dictionary creations. If the version field of this callbacks - structure is not one of the defined ones for CFDictionary, the - behavior is undefined. The retain field may be NULL, in which - case the CFDictionary will do nothing to add a retain to values - as they are put into the dictionary. The release field may be - NULL, in which case the CFDictionary will do nothing to remove - the dictionary's retain (if any) on the values when the - dictionary is destroyed or a key-value pair is removed. If the - copyDescription field is NULL, the dictionary will create a - simple description for a value. If the equal field is NULL, the - dictionary will use pointer equality to test for equality of - values. This callbacks parameter itself may be NULL, which is - treated as if a valid structure of version 0 with all fields - NULL had been passed in. Otherwise, - if any of the fields are not valid pointers to functions - of the correct type, or this parameter is not a valid - pointer to a CFDictionaryValueCallBacks callbacks structure, - the behavior is undefined. If any of the values put into the - dictionary is not one understood by one of the callback functions - the behavior when that callback function is used is undefined. - @result A reference to the new mutable CFDictionary. -*/ -CF_EXPORT -CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks); - -/*! - @function CFDictionaryCreateMutableCopy - Creates a new mutable dictionary with the key-value pairs from - the given dictionary. - @param allocator The CFAllocator which should be used to allocate - memory for the dictionary and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param capacity A hint about the number of values that will be held - by the CFDictionary. Pass 0 for no hint. The implementation may - ignore this hint, or may use it to optimize various - operations. A dictionary's actual capacity is only limited by - address space and available memory constraints). - This parameter must be greater than or equal - to the count of the dictionary which is to be copied, or the - behavior is undefined. If this parameter is negative, the - behavior is undefined. - @param theDict The dictionary which is to be copied. The keys and values - from the dictionary are copied as pointers into the new - dictionary (that is, the values themselves are copied, not - that which the values point to, if anything). However, the - keys and values are also retained by the new dictionary using - the retain function of the original dictionary. - The count of the new dictionary will be the same as the - given dictionary. The new dictionary uses the same callbacks - as the dictionary to be copied. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @result A reference to the new mutable CFDictionary. -*/ -CF_EXPORT -CFMutableDictionaryRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDictionaryRef theDict); - -/*! - @function CFDictionaryGetCount - Returns the number of values currently in the dictionary. - @param theDict The dictionary to be queried. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @result The number of values in the dictionary. -*/ -CF_EXPORT -CFIndex CFDictionaryGetCount(CFDictionaryRef theDict); - -/*! - @function CFDictionaryGetCountOfKey - Counts the number of times the given key occurs in the dictionary. - @param theDict The dictionary to be searched. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @param key The key for which to find matches in the dictionary. The - hash() and equal() key callbacks provided when the dictionary - was created are used to compare. If the hash() key callback - was NULL, the key is treated as a pointer and converted to - an integer. If the equal() key callback was NULL, pointer - equality (in C, ==) is used. If key, or any of the keys in - the dictionary, are not understood by the equal() callback, - the behavior is undefined. - @result Returns 1 if a matching key is used by the dictionary, - 0 otherwise. -*/ -CF_EXPORT -CFIndex CFDictionaryGetCountOfKey(CFDictionaryRef theDict, const void *key); - -/*! - @function CFDictionaryGetCountOfValue - Counts the number of times the given value occurs in the dictionary. - @param theDict The dictionary to be searched. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @param value The value for which to find matches in the dictionary. The - equal() callback provided when the dictionary was created is - used to compare. If the equal() value callback was NULL, pointer - equality (in C, ==) is used. If value, or any of the values in - the dictionary, are not understood by the equal() callback, - the behavior is undefined. - @result The number of times the given value occurs in the dictionary. -*/ -CF_EXPORT -CFIndex CFDictionaryGetCountOfValue(CFDictionaryRef theDict, const void *value); - -/*! - @function CFDictionaryContainsKey - Reports whether or not the key is in the dictionary. - @param theDict The dictionary to be searched. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @param key The key for which to find matches in the dictionary. The - hash() and equal() key callbacks provided when the dictionary - was created are used to compare. If the hash() key callback - was NULL, the key is treated as a pointer and converted to - an integer. If the equal() key callback was NULL, pointer - equality (in C, ==) is used. If key, or any of the keys in - the dictionary, are not understood by the equal() callback, - the behavior is undefined. - @result true, if the key is in the dictionary, otherwise false. -*/ -CF_EXPORT -Boolean CFDictionaryContainsKey(CFDictionaryRef theDict, const void *key); - -/*! - @function CFDictionaryContainsValue - Reports whether or not the value is in the dictionary. - @param theDict The dictionary to be searched. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @param value The value for which to find matches in the dictionary. The - equal() callback provided when the dictionary was created is - used to compare. If the equal() callback was NULL, pointer - equality (in C, ==) is used. If value, or any of the values - in the dictionary, are not understood by the equal() callback, - the behavior is undefined. - @result true, if the value is in the dictionary, otherwise false. -*/ -CF_EXPORT -Boolean CFDictionaryContainsValue(CFDictionaryRef theDict, const void *value); - -/*! - @function CFDictionaryGetValue - Retrieves the value associated with the given key. - @param theDict The dictionary to be queried. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @param key The key for which to find a match in the dictionary. The - hash() and equal() key callbacks provided when the dictionary - was created are used to compare. If the hash() key callback - was NULL, the key is treated as a pointer and converted to - an integer. If the equal() key callback was NULL, pointer - equality (in C, ==) is used. If key, or any of the keys in - the dictionary, are not understood by the equal() callback, - the behavior is undefined. - @result The value with the given key in the dictionary, or NULL if - no key-value pair with a matching key exists. Since NULL - can be a valid value in some dictionaries, the function - CFDictionaryGetValueIfPresent() must be used to distinguish - NULL-no-found from NULL-is-the-value. -*/ -CF_EXPORT -const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key); - -/*! - @function CFDictionaryGetValueIfPresent - Retrieves the value associated with the given key. - @param theDict The dictionary to be queried. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @param key The key for which to find a match in the dictionary. The - hash() and equal() key callbacks provided when the dictionary - was created are used to compare. If the hash() key callback - was NULL, the key is treated as a pointer and converted to - an integer. If the equal() key callback was NULL, pointer - equality (in C, ==) is used. If key, or any of the keys in - the dictionary, are not understood by the equal() callback, - the behavior is undefined. - @param value A pointer to memory which should be filled with the - pointer-sized value if a matching key is found. If no key - match is found, the contents of the storage pointed to by - this parameter are undefined. This parameter may be NULL, - in which case the value from the dictionary is not returned - (but the return value of this function still indicates - whether or not the key-value pair was present). - @result true, if a matching key was found, false otherwise. -*/ -CF_EXPORT -Boolean CFDictionaryGetValueIfPresent(CFDictionaryRef theDict, const void *key, const void **value); - -/*! - @function CFDictionaryGetKeysAndValues - Fills the two buffers with the keys and values from the dictionary. - @param theDict The dictionary to be queried. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @param keys A C array of pointer-sized values to be filled with keys - from the dictionary. The keys and values C arrays are parallel - to each other (that is, the items at the same indices form a - key-value pair from the dictionary). This parameter may be NULL - if the keys are not desired. If this parameter is not a valid - pointer to a C array of at least CFDictionaryGetCount() pointers, - or NULL, the behavior is undefined. - @param values A C array of pointer-sized values to be filled with values - from the dictionary. The keys and values C arrays are parallel - to each other (that is, the items at the same indices form a - key-value pair from the dictionary). This parameter may be NULL - if the values are not desired. If this parameter is not a valid - pointer to a C array of at least CFDictionaryGetCount() pointers, - or NULL, the behavior is undefined. -*/ -CF_EXPORT -void CFDictionaryGetKeysAndValues(CFDictionaryRef theDict, const void **keys, const void **values); - -/*! - @function CFDictionaryApplyFunction - Calls a function once for each value in the dictionary. - @param theDict The dictionary to be queried. If this parameter is - not a valid CFDictionary, the behavior is undefined. - @param applier The callback function to call once for each value in - the dictionary. If this parameter is not a - pointer to a function of the correct prototype, the behavior - is undefined. If there are keys or values which the - applier function does not expect or cannot properly apply - to, the behavior is undefined. - @param context A pointer-sized user-defined value, which is passed - as the third parameter to the applier function, but is - otherwise unused by this function. If the context is not - what is expected by the applier function, the behavior is - undefined. -*/ -CF_EXPORT -void CFDictionaryApplyFunction(CFDictionaryRef theDict, CFDictionaryApplierFunction applier, void *context); - -/*! - @function CFDictionaryAddValue - Adds the key-value pair to the dictionary if no such key already exists. - @param theDict The dictionary to which the value is to be added. If this - parameter is not a valid mutable CFDictionary, the behavior is - undefined. - @param key The key of the value to add to the dictionary. The key is - retained by the dictionary using the retain callback provided - when the dictionary was created. If the key is not of the sort - expected by the retain callback, the behavior is undefined. If - a key which matches this key is already present in the dictionary, - this function does nothing ("add if absent"). - @param value The value to add to the dictionary. The value is retained - by the dictionary using the retain callback provided when the - dictionary was created. If the value is not of the sort expected - by the retain callback, the behavior is undefined. -*/ -CF_EXPORT -void CFDictionaryAddValue(CFMutableDictionaryRef theDict, const void *key, const void *value); - -/*! - @function CFDictionarySetValue - Sets the value of the key in the dictionary. - @param theDict The dictionary to which the value is to be set. If this - parameter is not a valid mutable CFDictionary, the behavior is - undefined. - @param key The key of the value to set into the dictionary. If a key - which matches this key is already present in the dictionary, only - the value is changed ("add if absent, replace if present"). If - no key matches the given key, the key-value pair is added to the - dictionary. If added, the key is retained by the dictionary, - using the retain callback provided - when the dictionary was created. If the key is not of the sort - expected by the key retain callback, the behavior is undefined. - @param value The value to add to or replace into the dictionary. The value - is retained by the dictionary using the retain callback provided - when the dictionary was created, and the previous value if any is - released. If the value is not of the sort expected by the - retain or release callbacks, the behavior is undefined. -*/ -CF_EXPORT -void CFDictionarySetValue(CFMutableDictionaryRef theDict, const void *key, const void *value); - -/*! - @function CFDictionaryReplaceValue - Replaces the value of the key in the dictionary. - @param theDict The dictionary to which the value is to be replaced. If this - parameter is not a valid mutable CFDictionary, the behavior is - undefined. - @param key The key of the value to replace in the dictionary. If a key - which matches this key is present in the dictionary, the value - is changed to the given value, otherwise this function does - nothing ("replace if present"). - @param value The value to replace into the dictionary. The value - is retained by the dictionary using the retain callback provided - when the dictionary was created, and the previous value is - released. If the value is not of the sort expected by the - retain or release callbacks, the behavior is undefined. -*/ -CF_EXPORT -void CFDictionaryReplaceValue(CFMutableDictionaryRef theDict, const void *key, const void *value); - -/*! - @function CFDictionaryRemoveValue - Removes the value of the key from the dictionary. - @param theDict The dictionary from which the value is to be removed. If this - parameter is not a valid mutable CFDictionary, the behavior is - undefined. - @param key The key of the value to remove from the dictionary. If a key - which matches this key is present in the dictionary, the key-value - pair is removed from the dictionary, otherwise this function does - nothing ("remove if present"). -*/ -CF_EXPORT -void CFDictionaryRemoveValue(CFMutableDictionaryRef theDict, const void *key); - -/*! - @function CFDictionaryRemoveAllValues - Removes all the values from the dictionary, making it empty. - @param theDict The dictionary from which all of the values are to be - removed. If this parameter is not a valid mutable - CFDictionary, the behavior is undefined. -*/ -CF_EXPORT -void CFDictionaryRemoveAllValues(CFMutableDictionaryRef theDict); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFDICTIONARY__ */ - diff --git a/CFDictionary.h b/CFDictionary.h new file mode 120000 index 0000000..17e573f --- /dev/null +++ b/CFDictionary.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFDictionary.h \ No newline at end of file diff --git a/CFError.h b/CFError.h deleted file mode 100644 index 0b5ff49..0000000 --- a/CFError.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFError.h - Copyright (c) 2006-2014, Apple Inc. All rights reserved. -*/ - -/*! - @header CFError - @discussion - CFErrors are used to encompass information about errors. At minimum, errors are identified by their domain (a string) and an error code within that domain. In addition a "userInfo" dictionary supplied at creation time enables providing additional info that might be useful for the interpretation and reporting of the error. This dictionary can even contain an "underlying" error, which is wrapped as an error bubbles up through various layers. - - CFErrors have the ability to provide human-readable descriptions for the errors; in fact, they are designed to provide localizable, end-user presentable errors that can appear in the UI. CFError has a number of predefined userInfo keys to enable developers to supply the info. - - Usage recommendation for CFErrors is to return them as by-ref parameters in functions. This enables the caller to pass NULL in when they don't actually want information about the error. The presence of an error should be reported by other means, for instance a NULL or false return value from the function call proper: - - CFError *error; - if (!ReadFromFile(fd, &error)) { - ... process error ... - CFRelease(error); // If an error occurs, the returned CFError must be released. - } - - It is the responsibility of anyone returning CFErrors this way to: - - Not touch the error argument if no error occurs - - Create and assign the error for return only if the error argument is non-NULL - - In addition, it's recommended that CFErrors be used in error situations only (not status), and where there are multiple possible errors to distinguish between. For instance there is no plan to add CFErrors to existing APIs in CF which currently don't return errors; in many cases, there is one possible reason for failure, and a false or NULL return is enough to indicate it. - - CFError is toll-free bridged to NSError in Foundation. NSError in Foundation has some additional guidelines which makes it easy to automatically report errors to users and even try to recover from them. See http://developer.apple.com/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorHandling/chapter_1_section_1.html for more info on NSError programming guidelines. -*/ - -#if !defined(__COREFOUNDATION_CFERROR__) -#define __COREFOUNDATION_CFERROR__ 1 - -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -/*! - @typedef CFErrorRef - This is the type of a reference to CFErrors. CFErrorRef is toll-free bridged with NSError. -*/ -typedef struct CF_BRIDGED_TYPE(NSError) __CFError * CFErrorRef; - -/*! - @function CFErrorGetTypeID - Returns the type identifier of all CFError instances. -*/ -CF_EXPORT -CFTypeID CFErrorGetTypeID(void) CF_AVAILABLE(10_5, 2_0); - - -// Predefined domains; value of "code" will correspond to preexisting values in these domains. -CF_EXPORT const CFStringRef kCFErrorDomainPOSIX CF_AVAILABLE(10_5, 2_0); -CF_EXPORT const CFStringRef kCFErrorDomainOSStatus CF_AVAILABLE(10_5, 2_0); -CF_EXPORT const CFStringRef kCFErrorDomainMach CF_AVAILABLE(10_5, 2_0); -CF_EXPORT const CFStringRef kCFErrorDomainCocoa CF_AVAILABLE(10_5, 2_0); - -// Keys in userInfo for localizable, end-user presentable error messages. At minimum provide one of first two; ideally provide all three. -CF_EXPORT const CFStringRef kCFErrorLocalizedDescriptionKey CF_AVAILABLE(10_5, 2_0); // Key to identify the end user-presentable description in userInfo. -CF_EXPORT const CFStringRef kCFErrorLocalizedFailureReasonKey CF_AVAILABLE(10_5, 2_0); // Key to identify the end user-presentable failure reason in userInfo. -CF_EXPORT const CFStringRef kCFErrorLocalizedRecoverySuggestionKey CF_AVAILABLE(10_5, 2_0); // Key to identify the end user-presentable recovery suggestion in userInfo. - -// If you do not have localizable error strings, you can provide a value for this key instead. -CF_EXPORT const CFStringRef kCFErrorDescriptionKey CF_AVAILABLE(10_5, 2_0); // Key to identify the description in the userInfo dictionary. Should be a complete sentence if possible. Should not contain domain name or error code. - -// Other keys in userInfo. -CF_EXPORT const CFStringRef kCFErrorUnderlyingErrorKey CF_AVAILABLE(10_5, 2_0); // Key to identify the underlying error in userInfo. -CF_EXPORT const CFStringRef kCFErrorURLKey CF_AVAILABLE(10_7, 5_0); // Key to identify associated URL in userInfo. Typically one of this or kCFErrorFilePathKey is provided. -CF_EXPORT const CFStringRef kCFErrorFilePathKey CF_AVAILABLE(10_7, 5_0); // Key to identify associated file path in userInfo. Typically one of this or kCFErrorURLKey is provided. - - -/*! - @function CFErrorCreate - @abstract Creates a new CFError. - @param allocator The CFAllocator which should be used to allocate memory for the error. This parameter may be NULL in which case the - current default CFAllocator is used. If this reference is not a valid CFAllocator, the behavior is undefined. - @param domain A CFString identifying the error domain. If this reference is NULL or is otherwise not a valid CFString, the behavior is undefined. - @param code A CFIndex identifying the error code. The code is interpreted within the context of the error domain. - @param userInfo A CFDictionary created with kCFCopyStringDictionaryKeyCallBacks and kCFTypeDictionaryValueCallBacks. It will be copied with CFDictionaryCreateCopy(). - If no userInfo dictionary is desired, NULL may be passed in as a convenience, in which case an empty userInfo dictionary will be assigned. - @result A reference to the new CFError. -*/ -CF_EXPORT -CFErrorRef CFErrorCreate(CFAllocatorRef allocator, CFStringRef domain, CFIndex code, CFDictionaryRef userInfo) CF_AVAILABLE(10_5, 2_0); - -/*! - @function CFErrorCreateWithUserInfoKeysAndValues - @abstract Creates a new CFError without having to create an intermediate userInfo dictionary. - @param allocator The CFAllocator which should be used to allocate memory for the error. This parameter may be NULL in which case the - current default CFAllocator is used. If this reference is not a valid CFAllocator, the behavior is undefined. - @param domain A CFString identifying the error domain. If this reference is NULL or is otherwise not a valid CFString, the behavior is undefined. - @param code A CFIndex identifying the error code. The code is interpreted within the context of the error domain. - @param userInfoKeys An array of numUserInfoValues CFStrings used as keys in creating the userInfo dictionary. NULL is valid only if numUserInfoValues is 0. - @param userInfoValues An array of numUserInfoValues CF types used as values in creating the userInfo dictionary. NULL is valid only if numUserInfoValues is 0. - @param numUserInfoValues CFIndex representing the number of keys and values in the userInfoKeys and userInfoValues arrays. - @result A reference to the new CFError. numUserInfoValues CF types are gathered from each of userInfoKeys and userInfoValues to create the userInfo dictionary. -*/ -CF_EXPORT -CFErrorRef CFErrorCreateWithUserInfoKeysAndValues(CFAllocatorRef allocator, CFStringRef domain, CFIndex code, const void *const *userInfoKeys, const void *const *userInfoValues, CFIndex numUserInfoValues) CF_AVAILABLE(10_5, 2_0); - -/*! - @function CFErrorGetDomain - @abstract Returns the error domain the CFError was created with. - @param err The CFError whose error domain is to be returned. If this reference is not a valid CFError, the behavior is undefined. - @result The error domain of the CFError. Since this is a "Get" function, the caller shouldn't CFRelease the return value. -*/ -CF_EXPORT -CFStringRef CFErrorGetDomain(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); - -/*! - @function CFErrorGetCode - @abstract Returns the error code the CFError was created with. - @param err The CFError whose error code is to be returned. If this reference is not a valid CFError, the behavior is undefined. - @result The error code of the CFError (not an error return for the current call). -*/ -CF_EXPORT -CFIndex CFErrorGetCode(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); - -/*! - @function CFErrorCopyUserInfo - @abstract Returns CFError userInfo dictionary. - @discussion Returns a dictionary containing the same keys and values as in the userInfo dictionary the CFError was created with. Returns an empty dictionary if NULL was supplied to CFErrorCreate(). - @param err The CFError whose error user info is to be returned. If this reference is not a valid CFError, the behavior is undefined. - @result The user info of the CFError. -*/ -CF_EXPORT -CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); - -/*! - @function CFErrorCopyDescription - @abstract Returns a human-presentable description for the error. CFError creators should strive to make sure the return value is human-presentable and localized by providing a value for kCFErrorLocalizedDescriptionKey at the time of CFError creation. - @discussion This is a complete sentence or two which says what failed and why it failed. Rules for computing the return value: - - Look for kCFErrorLocalizedDescriptionKey in the user info and if not NULL, returns that as-is. - - Otherwise, if there is a kCFErrorLocalizedFailureReasonKey in the user info, generate an error from that. Something like: "Operation code not be completed. " + kCFErrorLocalizedFailureReasonKey - - Otherwise, generate a semi-user presentable string from kCFErrorDescriptionKey, the domain, and code. Something like: "Operation could not be completed. Error domain/code occurred. " or "Operation could not be completed. " + kCFErrorDescriptionKey + " (Error domain/code)" - Toll-free bridged NSError instances might provide additional behaviors for manufacturing a description string. Do not count on the exact contents or format of the returned string, it might change. - @param err The CFError whose description is to be returned. If this reference is not a valid CFError, the behavior is undefined. - @result A CFString with human-presentable description of the CFError. Never NULL. -*/ -CF_EXPORT -CFStringRef CFErrorCopyDescription(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); - -/*! - @function CFErrorCopyFailureReason - @abstract Returns a human-presentable failure reason for the error. May return NULL. CFError creators should strive to make sure the return value is human-presentable and localized by providing a value for kCFErrorLocalizedFailureReasonKey at the time of CFError creation. - @discussion This is a complete sentence which describes why the operation failed. In many cases this will be just the "because" part of the description (but as a complete sentence, which makes localization easier). By default this looks for kCFErrorLocalizedFailureReasonKey in the user info. Toll-free bridged NSError instances might provide additional behaviors for manufacturing this value. If no user-presentable string is available, returns NULL. - Example Description: "Could not save file 'Letter' in folder 'Documents' because the volume 'MyDisk' doesn't have enough space." - Corresponding FailureReason: "The volume 'MyDisk' doesn't have enough space." - @param err The CFError whose failure reason is to be returned. If this reference is not a valid CFError, the behavior is undefined. - @result A CFString with the localized, end-user presentable failure reason of the CFError, or NULL. -*/ -CF_EXPORT -CFStringRef CFErrorCopyFailureReason(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); - -/*! - @function CFErrorCopyRecoverySuggestion - @abstract Returns a human presentable recovery suggestion for the error. May return NULL. CFError creators should strive to make sure the return value is human-presentable and localized by providing a value for kCFErrorLocalizedRecoverySuggestionKey at the time of CFError creation. - @discussion This is the string that can be displayed as the "informative" (aka "secondary") message on an alert panel. By default this looks for kCFErrorLocalizedRecoverySuggestionKey in the user info. Toll-free bridged NSError instances might provide additional behaviors for manufacturing this value. If no user-presentable string is available, returns NULL. - Example Description: "Could not save file 'Letter' in folder 'Documents' because the volume 'MyDisk' doesn't have enough space." - Corresponding RecoverySuggestion: "Remove some files from the volume and try again." - @param err The CFError whose recovery suggestion is to be returned. If this reference is not a valid CFError, the behavior is undefined. - @result A CFString with the localized, end-user presentable recovery suggestion of the CFError, or NULL. -*/ -CF_EXPORT -CFStringRef CFErrorCopyRecoverySuggestion(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); - - - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFERROR__ */ - diff --git a/CFError.h b/CFError.h new file mode 120000 index 0000000..56eede3 --- /dev/null +++ b/CFError.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFError.h \ No newline at end of file diff --git a/CFError_Private.h b/CFError_Private.h deleted file mode 100644 index e053bda..0000000 --- a/CFError_Private.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFError_Private.h - Copyright (c) 2006-2014, Apple Inc. All rights reserved. - - This is Apple-internal SPI for CFError. -*/ - -#if !defined(__COREFOUNDATION_CFERRORPRIVATE__) -#define __COREFOUNDATION_CFERRORPRIVATE__ 1 - -#include - -CF_EXTERN_C_BEGIN - -/* 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. -*/ -typedef CFTypeRef (*CFErrorUserInfoKeyCallBack)(CFErrorRef err, CFStringRef key); -CF_EXPORT void CFErrorSetCallBackForDomain(CFStringRef domainName, CFErrorUserInfoKeyCallBack callBack) CF_AVAILABLE(10_5, 2_0); -CF_EXPORT CFErrorUserInfoKeyCallBack CFErrorGetCallBackForDomain(CFStringRef domainName) CF_AVAILABLE(10_5, 2_0); - - -/* 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. -*/ -CF_EXPORT const CFStringRef kCFErrorDebugDescriptionKey CF_AVAILABLE(10_5, 2_0); - - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFERRORPRIVATE__ */ - diff --git a/CFError_Private.h b/CFError_Private.h new file mode 120000 index 0000000..d0a3ec0 --- /dev/null +++ b/CFError_Private.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFError_Private.h \ No newline at end of file diff --git a/CFFileDescriptor.h b/CFFileDescriptor.h deleted file mode 100644 index 0e9b86c..0000000 --- a/CFFileDescriptor.h +++ /dev/null @@ -1,39 +0,0 @@ -#if !defined(__COREFOUNDATION_CFFILEDESCRIPTOR__) -#define __COREFOUNDATION_CFFILEDESCRIPTOR__ 1 - -#include - -CF_EXTERN_C_BEGIN - -typedef int CFFileDescriptorNativeDescriptor; - -typedef struct __CFFileDescriptor * CFFileDescriptorRef; - -enum { - kCFFileDescriptorReadCallBack = 1UL << 0, - kCFFileDescriptorWriteCallBack = 1UL << 1 -}; - -typedef void (*CFFileDescriptorCallBack)(CFFileDescriptorRef f, CFOptionFlags callBackTypes, void *info); - -typedef struct { - CFIndex version; - void *info; - void *(*retain)(void *info); - void (*release)(void *info); - CFStringRef (*copyDescription)(void *info); -} CFFileDescriptorContext; - -CF_EXPORT CFTypeID CFFileDescriptorGetTypeID(void); -CF_EXPORT CFFileDescriptorRef CFFileDescriptorCreate(CFAllocatorRef allocator, CFFileDescriptorNativeDescriptor fd, Boolean closeOnInvalidate, CFFileDescriptorCallBack callout, const CFFileDescriptorContext *context); -CF_EXPORT CFFileDescriptorNativeDescriptor CFFileDescriptorGetNativeDescriptor(CFFileDescriptorRef f); -CF_EXPORT void CFFileDescriptorGetContext(CFFileDescriptorRef f, CFFileDescriptorContext *context); -CF_EXPORT void CFFileDescriptorEnableCallBacks(CFFileDescriptorRef f, CFOptionFlags callBackTypes); -CF_EXPORT void CFFileDescriptorDisableCallBacks(CFFileDescriptorRef f, CFOptionFlags callBackTypes); -CF_EXPORT void CFFileDescriptorInvalidate(CFFileDescriptorRef f); -CF_EXPORT Boolean CFFileDescriptorIsValid(CFFileDescriptorRef f); -CF_EXPORT CFRunLoopSourceRef CFFileDescriptorCreateRunLoopSource(CFAllocatorRef allocator, CFFileDescriptorRef f, CFIndex order); - -CF_EXTERN_C_END - -#endif diff --git a/CFFileDescriptor.h b/CFFileDescriptor.h new file mode 120000 index 0000000..fbfef9d --- /dev/null +++ b/CFFileDescriptor.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFFileDescriptor.h \ No newline at end of file diff --git a/CFFileSecurity.h b/CFFileSecurity.h deleted file mode 100644 index f950640..0000000 --- a/CFFileSecurity.h +++ /dev/null @@ -1,47 +0,0 @@ -#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION - -#if !defined(__COREFOUNDATION_CFFILESECURITY__) -#define __COREFOUNDATION_CFFILESECURITY__ 1 - -#include -#include -#include -#include - -CF_EXTERN_C_BEGIN - -#define kCFFileSecurityRemoveACL(acl_t) _FILESEC_REMOVE_ACL - -enum { - kCFFileSecurityClearOwner = 1UL << 0, - kCFFileSecurityClearGroup = 1UL << 1, - kCFFileSecurityClearMode = 1UL << 2, - kCFFileSecurityClearOwnerUUID = 1UL << 3, - kCFFileSecurityClearGroupUUID = 1UL << 4, - kCFFileSecurityClearAccessControlList = 1UL << 5 -}; - -typedef struct __CFFileSecurity* CFFileSecurityRef; - -CF_EXPORT CFTypeID CFFileSecurityGetTypeID(void); -CF_EXPORT CFFileSecurityRef CFFileSecurityCreate(CFAllocatorRef allocator); -CF_EXPORT CFFileSecurityRef CFFileSecurityCreateCopy(CFAllocatorRef allocator, CFFileSecurityRef fileSec); -CF_EXPORT Boolean CFFileSecurityCopyOwnerUUID(CFFileSecurityRef fileSec, CFUUIDRef *ownerUUID); -CF_EXPORT Boolean CFFileSecuritySetOwnerUUID(CFFileSecurityRef fileSec, CFUUIDRef ownerUUID); -CF_EXPORT Boolean CFFileSecurityCopyGroupUUID(CFFileSecurityRef fileSec, CFUUIDRef *groupUUID); -CF_EXPORT Boolean CFFileSecuritySetGroupUUID(CFFileSecurityRef fileSec, CFUUIDRef groupUUID); -CF_EXPORT Boolean CFFileSecurityCopyAccessControlList(CFFileSecurityRef fileSec, acl_t *accessControlList); -CF_EXPORT Boolean CFFileSecuritySetAccessControlList(CFFileSecurityRef fileSec, acl_t accessControlList); -CF_EXPORT Boolean CFFileSecurityGetOwner(CFFileSecurityRef fileSec, uid_t *owner); -CF_EXPORT Boolean CFFileSecuritySetOwner(CFFileSecurityRef fileSec, uid_t owner); -CF_EXPORT Boolean CFFileSecurityGetGroup(CFFileSecurityRef fileSec, gid_t *group); -CF_EXPORT Boolean CFFileSecuritySetGroup(CFFileSecurityRef fileSec, gid_t group); -CF_EXPORT Boolean CFFileSecurityGetMode(CFFileSecurityRef fileSec, mode_t *mode); -CF_EXPORT Boolean CFFileSecuritySetMode(CFFileSecurityRef fileSec, mode_t mode); -CF_EXPORT Boolean CFFileSecurityClearProperties(CFFileSecurityRef fileSec, CFOptionFlags clearPropertyMask); - -CF_EXTERN_C_END - -#endif -#endif - diff --git a/CFFileSecurity.h b/CFFileSecurity.h new file mode 120000 index 0000000..a552ca6 --- /dev/null +++ b/CFFileSecurity.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFFileSecurity.h \ No newline at end of file diff --git a/CFICUConverters.h b/CFICUConverters.h deleted file mode 100644 index a73cdcd..0000000 --- a/CFICUConverters.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* - * CFICUConverters.h - * CoreFoundation - * - * Created by Aki Inoue on 07/12/04. - * Copyright (c) 2007-2014, Apple Inc. All rights reserved. - * - */ - -#include - -CF_PRIVATE const char *__CFStringEncodingGetICUName(CFStringEncoding encoding); - -CF_PRIVATE CFStringEncoding __CFStringEncodingGetFromICUName(const char *icuName); - - -CF_PRIVATE CFIndex __CFStringEncodingICUToBytes(const char *icuName, uint32_t flags, const UniChar *characters, CFIndex numChars, CFIndex *usedCharLen, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); -CF_PRIVATE CFIndex __CFStringEncodingICUToUnicode(const char *icuName, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, CFIndex *usedByteLen, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); -CF_PRIVATE CFIndex __CFStringEncodingICUCharLength(const char *icuName, uint32_t flags, const uint8_t *bytes, CFIndex numBytes); -CF_PRIVATE CFIndex __CFStringEncodingICUByteLength(const char *icuName, uint32_t flags, const UniChar *characters, CFIndex numChars); - -// The caller is responsible for freeing the memory (use CFAllocatorDeallocate) -CF_PRIVATE CFStringEncoding *__CFStringEncodingCreateICUEncodings(CFAllocatorRef allocator, CFIndex *numberOfIndex); - - diff --git a/CFICUConverters.h b/CFICUConverters.h new file mode 120000 index 0000000..6cd3532 --- /dev/null +++ b/CFICUConverters.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFICUConverters.h \ No newline at end of file diff --git a/CFICULogging.h b/CFICULogging.h deleted file mode 100644 index e4529ee..0000000 --- a/CFICULogging.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* - CFICULogging.h - Copyright (c) 2008-2014, Apple Inc. All rights reserved. -*/ - -/* - This file is for the use of the CoreFoundation project only. -*/ - -#if !defined(__COREFOUNDATION_CFICULOGGING__) -#define __COREFOUNDATION_CFICULOGGING__ 1 - -#include -#include -#include -#include -#include -#include - -// ucal - - -// ucal -#define __cficu_ucal_open ucal_open -#define __cficu_ucal_close ucal_close -#define __cficu_ucal_clone ucal_clone -#define __cficu_ucal_setAttribute ucal_setAttribute -#define __cficu_ucal_getAttribute ucal_getAttribute -#define __cficu_ucal_setGregorianChange ucal_setGregorianChange -#define __cficu_ucal_getGregorianChange ucal_getGregorianChange -#define __cficu_ucal_getMillis ucal_getMillis -#define __cficu_ucal_setMillis ucal_setMillis -#define __cficu_ucal_set ucal_set -#define __cficu_ucal_get ucal_get -#define __cficu_ucal_getDayOfWeekType ucal_getDayOfWeekType -#define __cficu_ucal_getWeekendTransition ucal_getWeekendTransition -#define __cficu_ucal_isWeekend ucal_isWeekend -#define __cficu_ucal_clear ucal_clear -#define __cficu_ucal_getLimit ucal_getLimit -#define __cficu_ucal_add ucal_add -#define __cficu_ucal_roll ucal_roll -#define __cficu_ucal_getFieldDifference ucal_getFieldDifference -#define __cficu_ucal_getNow ucal_getNow -#define __cficu_ucal_setTimeZone ucal_setTimeZone -// udatpg -#define __cficu_udatpg_open udatpg_open -#define __cficu_udatpg_close udatpg_close -#define __cficu_udatpg_getSkeleton udatpg_getSkeleton -#define __cficu_udatpg_getBestPattern udatpg_getBestPattern -// udat -#define __cficu_udat_applyPattern udat_applyPattern -#define __cficu_udat_applyPatternRelative udat_applyPatternRelative -#define __cficu_udat_clone udat_clone -#define __cficu_udat_close udat_close -#define __cficu_udat_countSymbols udat_countSymbols -#define __cficu_udat_format udat_format -#define __cficu_udat_get2DigitYearStart udat_get2DigitYearStart -#define __cficu_udat_getCalendar udat_getCalendar -#define __cficu_udat_getSymbols udat_getSymbols -#define __cficu_udat_isLenient udat_isLenient -#define __cficu_udat_open udat_open -#define __cficu_udat_parseCalendar udat_parseCalendar -#define __cficu_udat_set2DigitYearStart udat_set2DigitYearStart -#define __cficu_udat_setCalendar udat_setCalendar -#define __cficu_udat_setLenient udat_setLenient -#define __cficu_udat_setSymbols udat_setSymbols -#define __cficu_udat_toPattern udat_toPattern -#define __cficu_udat_toPatternRelativeDate udat_toPatternRelativeDate -#define __cficu_udat_toPatternRelativeTime udat_toPatternRelativeTime -#define __cficu_unum_applyPattern unum_applyPattern -#define __cficu_unum_close unum_close -#define __cficu_unum_formatDecimal unum_formatDecimal -#define __cficu_unum_formatDouble unum_formatDouble -#define __cficu_unum_getAttribute unum_getAttribute -#define __cficu_unum_getDoubleAttribute unum_getDoubleAttribute -#define __cficu_unum_getSymbol unum_getSymbol -#define __cficu_unum_getTextAttribute unum_getTextAttribute -#define __cficu_unum_open unum_open -#define __cficu_unum_parse unum_parse -#define __cficu_unum_parseDecimal unum_parseDecimal -#define __cficu_unum_setAttribute unum_setAttribute -#define __cficu_unum_setDoubleAttribute unum_setDoubleAttribute -#define __cficu_unum_setSymbol unum_setSymbol -#define __cficu_unum_setTextAttribute unum_setTextAttribute -#define __cficu_unum_toPattern unum_toPattern -#define __cficu_udat_setContext udat_setContext -#define __cficu_udat_getContext udat_getContext -// ucurr -#define __cficu_ucurr_getDefaultFractionDigits ucurr_getDefaultFractionDigits -#define __cficu_ucurr_getRoundingIncrement ucurr_getRoundingIncrement -// unum -#define __cficu_unum_setContext unum_setContext -#define __cficu_unum_getContext unum_getContext - -#endif diff --git a/CFICULogging.h b/CFICULogging.h new file mode 120000 index 0000000..0434d8f --- /dev/null +++ b/CFICULogging.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFICULogging.h \ No newline at end of file diff --git a/CFInternal.h b/CFInternal.h deleted file mode 100644 index 6b8e9ed..0000000 --- a/CFInternal.h +++ /dev/null @@ -1,805 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFInternal.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -/* - NOT TO BE USED OUTSIDE CF! -*/ - -#if !CF_BUILDING_CF - #error The header file CFInternal.h is for the exclusive use of CoreFoundation. No other project should include it. -#endif - -#if !defined(__COREFOUNDATION_CFINTERNAL__) -#define __COREFOUNDATION_CFINTERNAL__ 1 - - -#define __CF_COMPILE_YEAR__ (__DATE__[7] * 1000 + __DATE__[8] * 100 + __DATE__[9] * 10 + __DATE__[10] - 53328) -#define __CF_COMPILE_MONTH__ ((__DATE__[1] + __DATE__[2] == 207) ? 1 : \ - (__DATE__[1] + __DATE__[2] == 199) ? 2 : \ - (__DATE__[1] + __DATE__[2] == 211) ? 3 : \ - (__DATE__[1] + __DATE__[2] == 226) ? 4 : \ - (__DATE__[1] + __DATE__[2] == 218) ? 5 : \ - (__DATE__[1] + __DATE__[2] == 227) ? 6 : \ - (__DATE__[1] + __DATE__[2] == 225) ? 7 : \ - (__DATE__[1] + __DATE__[2] == 220) ? 8 : \ - (__DATE__[1] + __DATE__[2] == 213) ? 9 : \ - (__DATE__[1] + __DATE__[2] == 215) ? 10 : \ - (__DATE__[1] + __DATE__[2] == 229) ? 11 : \ - (__DATE__[1] + __DATE__[2] == 200) ? 12 : 0) -#define __CF_COMPILE_DAY__ (__DATE__[4] * 10 + __DATE__[5] - (__DATE__[4] == ' ' ? 368 : 528)) -#define __CF_COMPILE_DATE__ (__CF_COMPILE_YEAR__ * 10000 + __CF_COMPILE_MONTH__ * 100 + __CF_COMPILE_DAY__) - -#define __CF_COMPILE_HOUR__ (__TIME__[0] * 10 + __TIME__[1] - 528) -#define __CF_COMPILE_MINUTE__ (__TIME__[3] * 10 + __TIME__[4] - 528) -#define __CF_COMPILE_SECOND__ (__TIME__[6] * 10 + __TIME__[7] - 528) -#define __CF_COMPILE_TIME__ (__CF_COMPILE_HOUR__ * 10000 + __CF_COMPILE_MINUTE__ * 100 + __CF_COMPILE_SECOND__) - -#define __CF_COMPILE_SECOND_OF_DAY__ (__CF_COMPILE_HOUR__ * 3600 + __CF_COMPILE_MINUTE__ * 60 + __CF_COMPILE_SECOND__) - -// __CF_COMPILE_DAY_OF_EPOCH__ works within Gregorian years 2001 - 2099; the epoch is of course CF's epoch -#define __CF_COMPILE_DAY_OF_EPOCH__ ((__CF_COMPILE_YEAR__ - 2001) * 365 + (__CF_COMPILE_YEAR__ - 2001) / 4 \ - + ((__DATE__[1] + __DATE__[2] == 207) ? 0 : \ - (__DATE__[1] + __DATE__[2] == 199) ? 31 : \ - (__DATE__[1] + __DATE__[2] == 211) ? 59 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ - (__DATE__[1] + __DATE__[2] == 226) ? 90 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ - (__DATE__[1] + __DATE__[2] == 218) ? 120 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ - (__DATE__[1] + __DATE__[2] == 227) ? 151 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ - (__DATE__[1] + __DATE__[2] == 225) ? 181 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ - (__DATE__[1] + __DATE__[2] == 220) ? 212 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ - (__DATE__[1] + __DATE__[2] == 213) ? 243 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ - (__DATE__[1] + __DATE__[2] == 215) ? 273 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ - (__DATE__[1] + __DATE__[2] == 229) ? 304 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ - (__DATE__[1] + __DATE__[2] == 200) ? 334 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ - 365 + (__CF_COMPILE_YEAR__ % 4 == 0)) \ - + __CF_COMPILE_DAY__) - - -CF_EXTERN_C_BEGIN - -#include -#include -#include -#include -#include -#include -#include -#include -#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI || DEPLOYMENT_TARGET_LINUX -#include -#include -#include -#include -#include -#endif -#include - - -#if defined(__BIG_ENDIAN__) -#define __CF_BIG_ENDIAN__ 1 -#define __CF_LITTLE_ENDIAN__ 0 -#endif - -#if defined(__LITTLE_ENDIAN__) -#define __CF_LITTLE_ENDIAN__ 1 -#define __CF_BIG_ENDIAN__ 0 -#endif - - -#include - -CF_EXPORT const char *_CFProcessName(void); -CF_EXPORT CFStringRef _CFProcessNameString(void); - -CF_EXPORT Boolean _CFGetCurrentDirectory(char *path, int maxlen); - -CF_EXPORT CFArrayRef _CFGetWindowsBinaryDirectories(void); - -CF_EXPORT CFStringRef _CFStringCreateHostName(void); - -#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI -#include -CF_EXPORT void _CFMachPortInstallNotifyPort(CFRunLoopRef rl, CFStringRef mode); -#endif - - -CF_PRIVATE CFIndex __CFActiveProcessorCount(); - -#ifndef CLANG_ANALYZER_NORETURN -#if __has_feature(attribute_analyzer_noreturn) -#define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) -#else -#define CLANG_ANALYZER_NORETURN -#endif -#endif - -#if DEPLOYMENT_TARGET_WINDOWS -#define __builtin_unreachable() do { } while (0) -#endif - -#if defined(__i386__) || defined(__x86_64__) - #if defined(__GNUC__) - #define HALT do {asm __volatile__("int3"); kill(getpid(), 9); __builtin_unreachable(); } while (0) - #elif defined(_MSC_VER) - #define HALT do { DebugBreak(); abort(); __builtin_unreachable(); } while (0) - #else - #error Compiler not supported - #endif -#endif - - -#if defined(DEBUG) - #define __CFAssert(cond, prio, desc, a1, a2, a3, a4, a5) \ - do { \ - if (!(cond)) { \ - CFLog(prio, CFSTR(desc), a1, a2, a3, a4, a5); \ - /* HALT; */ \ - } \ - } while (0) -#else - #define __CFAssert(cond, prio, desc, a1, a2, a3, a4, a5) \ - do {} while (0) -#endif - -#define CFAssert(condition, priority, description) \ - __CFAssert((condition), (priority), description, 0, 0, 0, 0, 0) -#define CFAssert1(condition, priority, description, a1) \ - __CFAssert((condition), (priority), description, (a1), 0, 0, 0, 0) -#define CFAssert2(condition, priority, description, a1, a2) \ - __CFAssert((condition), (priority), description, (a1), (a2), 0, 0, 0) -#define CFAssert3(condition, priority, description, a1, a2, a3) \ - __CFAssert((condition), (priority), description, (a1), (a2), (a3), 0, 0) -#define CFAssert4(condition, priority, description, a1, a2, a3, a4) \ - __CFAssert((condition), (priority), description, (a1), (a2), (a3), (a4), 0) - -#define __kCFLogAssertion 3 - -// This CF-only log function uses no CF functionality, so it may be called anywhere within CF - including thread teardown or prior to full CF setup -CF_PRIVATE void _CFLogSimple(int32_t lev, char *format, ...); - -#if defined(DEBUG) -extern void __CFGenericValidateType_(CFTypeRef cf, CFTypeID type, const char *func); -#define __CFGenericValidateType(cf, type) __CFGenericValidateType_(cf, type, __PRETTY_FUNCTION__) -#else -#define __CFGenericValidateType(cf, type) ((void)0) -#endif - -#define CF_INFO_BITS (!!(__CF_BIG_ENDIAN__) * 3) -#define CF_RC_BITS (!!(__CF_LITTLE_ENDIAN__) * 3) - -/* Bit manipulation macros */ -/* Bits are numbered from 31 on left to 0 on right */ -/* May or may not work if you use them on bitfields in types other than UInt32, bitfields the full width of a UInt32, or anything else for which they were not designed. */ -/* In the following, N1 and N2 specify an inclusive range N2..N1 with N1 >= N2 */ -#define __CFBitfieldMask(N1, N2) ((((UInt32)~0UL) << (31UL - (N1) + (N2))) >> (31UL - N1)) -#define __CFBitfieldGetValue(V, N1, N2) (((V) & __CFBitfieldMask(N1, N2)) >> (N2)) -#define __CFBitfieldSetValue(V, N1, N2, X) ((V) = ((V) & ~__CFBitfieldMask(N1, N2)) | (((X) << (N2)) & __CFBitfieldMask(N1, N2))) -#define __CFBitfieldMaxValue(N1, N2) __CFBitfieldGetValue(0xFFFFFFFFUL, (N1), (N2)) - -#define __CFBitIsSet(V, N) (((V) & (1UL << (N))) != 0) -#define __CFBitSet(V, N) ((V) |= (1UL << (N))) -#define __CFBitClear(V, N) ((V) &= ~(1UL << (N))) - -// Foundation uses 20-40 -// Foundation knows about the value of __CFTSDKeyAutoreleaseData1 -enum { - __CFTSDKeyAllocator = 1, - __CFTSDKeyIsInCFLog = 2, - __CFTSDKeyIsInNSCache = 3, - __CFTSDKeyIsInGCDMainQ = 4, - __CFTSDKeyICUConverter = 7, - __CFTSDKeyCollatorLocale = 8, - __CFTSDKeyCollatorUCollator = 9, - __CFTSDKeyRunLoop = 10, - __CFTSDKeyRunLoopCntr = 11, - __CFTSDKeyMachMessageBoost = 12, // valid only in the context of a CFMachPort callout - __CFTSDKeyMachMessageHasVoucher = 13, - // autorelease pool stuff must be higher than run loop constants - __CFTSDKeyAutoreleaseData2 = 61, - __CFTSDKeyAutoreleaseData1 = 62, - __CFTSDKeyExceptionData = 63, -}; - -#define __kCFAllocatorTypeID_CONST 2 - -CF_INLINE CFAllocatorRef __CFGetDefaultAllocator(void) { - CFAllocatorRef allocator = (CFAllocatorRef)_CFGetTSD(__CFTSDKeyAllocator); - if (NULL == allocator) { - allocator = kCFAllocatorSystemDefault; - } - return allocator; -} - - -#if !defined(LLONG_MAX) - #if defined(_I64_MAX) - #define LLONG_MAX _I64_MAX - #else - #warning Arbitrarily defining LLONG_MAX - #define LLONG_MAX (int64_t)9223372036854775807 - #endif -#endif /* !defined(LLONG_MAX) */ - -#if !defined(LLONG_MIN) - #if defined(_I64_MIN) - #define LLONG_MIN _I64_MIN - #else - #warning Arbitrarily defining LLONG_MIN - #define LLONG_MIN (-LLONG_MAX - (int64_t)1) - #endif -#endif /* !defined(LLONG_MIN) */ - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) - #define __CFMin(A,B) ({__typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; }) - #define __CFMax(A,B) ({__typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) -#else /* __GNUC__ */ - #define __CFMin(A,B) ((A) < (B) ? (A) : (B)) - #define __CFMax(A,B) ((A) > (B) ? (A) : (B)) -#endif /* __GNUC__ */ - -/* Secret CFAllocator hint bits */ -#define __kCFAllocatorTempMemory 0x2 -#define __kCFAllocatorNoPointers 0x10 -#define __kCFAllocatorDoNotRecordEvent 0x100 -#define __kCFAllocatorGCScannedMemory 0x200 /* GC: memory should be scanned. */ -#define __kCFAllocatorGCObjectMemory 0x400 /* GC: memory needs to be finalized. */ - -CF_INLINE auto_memory_type_t CF_GET_GC_MEMORY_TYPE(CFOptionFlags flags) { - auto_memory_type_t type = (flags & __kCFAllocatorGCScannedMemory ? 0 : AUTO_UNSCANNED) | (flags & __kCFAllocatorGCObjectMemory ? AUTO_OBJECT : 0); - return type; -} - -CF_INLINE void __CFAssignWithWriteBarrier(void **location, void *value) { - if (kCFUseCollectableAllocator) { - objc_assign_strongCast((id)value, (id *)location); - } else { - *location = value; - } -} - -// Zero-retain count CFAllocator functions, i.e. memory that will be collected, no dealloc necessary -CF_EXPORT void *_CFAllocatorAllocateGC(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint); -CF_EXPORT void *_CFAllocatorReallocateGC(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint); -CF_EXPORT void _CFAllocatorDeallocateGC(CFAllocatorRef allocator, void *ptr); - -CF_EXPORT CFAllocatorRef _CFTemporaryMemoryAllocator(void); - -extern uint64_t __CFTimeIntervalToTSR(CFTimeInterval ti); -extern CFTimeInterval __CFTSRToTimeInterval(uint64_t tsr); -// use this instead of attempting to subtract mach_absolute_time() directly, because that can underflow and give an unexpected answer -CF_PRIVATE CFTimeInterval __CFTimeIntervalUntilTSR(uint64_t tsr); -CF_PRIVATE dispatch_time_t __CFTSRToDispatchTime(uint64_t tsr); -CF_PRIVATE uint64_t __CFTSRToNanoseconds(uint64_t tsr); - -extern CFStringRef __CFCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions); - -/* Enhanced string formatting support - */ -CF_PRIVATE CFDictionaryRef _CFStringGetFormatSpecifierConfiguration(CFStringRef aFormatString); -CF_PRIVATE CFStringRef _CFStringCopyWithFomatStringConfiguration(CFStringRef aFormatString, CFDictionaryRef formatConfiguration); -CF_PRIVATE CFStringRef _CFCopyResolvedFormatStringWithConfiguration(CFTypeRef anObject, CFDictionaryRef aConfiguration, CFDictionaryRef formatOptions); - -/* result is long long or int, depending on doLonglong -*/ -extern Boolean __CFStringScanInteger(CFStringInlineBuffer *buf, CFTypeRef locale, SInt32 *indexPtr, Boolean doLonglong, void *result); -extern Boolean __CFStringScanDouble(CFStringInlineBuffer *buf, CFTypeRef locale, SInt32 *indexPtr, double *resultPtr); -extern Boolean __CFStringScanHex(CFStringInlineBuffer *buf, SInt32 *indexPtr, unsigned *result); - -extern const char *__CFgetenv(const char *n); - -CF_PRIVATE Boolean __CFProcessIsRestricted(); - -// This is really about the availability of C99. We don't have that on Windows, but we should everywhere else. -#if DEPLOYMENT_TARGET_WINDOWS -#define STACK_BUFFER_DECL(T, N, C) T *N = (T *)_alloca((C) * sizeof(T)) -#else -#define STACK_BUFFER_DECL(T, N, C) T N[C] -#endif - - -CF_EXPORT void * __CFConstantStringClassReferencePtr; - -#ifdef __CONSTANT_CFSTRINGS__ - -#define CONST_STRING_DECL(S, V) const CFStringRef S = (const CFStringRef)__builtin___CFStringMakeConstantString(V); -#define PE_CONST_STRING_DECL(S, V) CF_PRIVATE const CFStringRef S = (const CFStringRef)__builtin___CFStringMakeConstantString(V); - -#else - -struct CF_CONST_STRING { - CFRuntimeBase _base; - uint8_t *_ptr; - uint32_t _length; -}; - -CF_EXPORT int __CFConstantStringClassReference[]; - -/* CFNetwork also has a copy of the CONST_STRING_DECL macro (for use on platforms without constant string support in cc); please warn cfnetwork-core@group.apple.com of any necessary changes to this macro. -- REW, 1/28/2002 */ - -#if __CF_BIG_ENDIAN__ - -#define CONST_STRING_DECL(S, V) \ -static struct CF_CONST_STRING __ ## S ## __ = {{(uintptr_t)&__CFConstantStringClassReference, {0x00, 0x00, 0x07, 0xc8}}, (uint8_t *)V, sizeof(V) - 1}; \ -const CFStringRef S = (CFStringRef) & __ ## S ## __; -#define PE_CONST_STRING_DECL(S, V) \ -static struct CF_CONST_STRING __ ## S ## __ = {{(uintptr_t)&__CFConstantStringClassReference, {0x00, 0x00, 0x07, 0xc8}}, (uint8_t *)V, sizeof(V) - 1}; \ -CF_PRIVATE const CFStringRef S = (CFStringRef) & __ ## S ## __; - -#elif __CF_LITTLE_ENDIAN__ - -#define CONST_STRING_DECL(S, V) \ -static struct CF_CONST_STRING __ ## S ## __ = {{(uintptr_t)&__CFConstantStringClassReference, {0xc8, 0x07, 0x00, 0x00}}, (uint8_t *)(V), sizeof(V) - 1}; \ -const CFStringRef S = (CFStringRef) & __ ## S ## __; -#define PE_CONST_STRING_DECL(S, V) \ -static struct CF_CONST_STRING __ ## S ## __ = {{(uintptr_t)&__CFConstantStringClassReference, {0xc8, 0x07, 0x00, 0x00}}, (uint8_t *)(V), sizeof(V) - 1}; \ -CF_PRIVATE const CFStringRef S = (CFStringRef) & __ ## S ## __; - -#endif - -#endif // __CONSTANT_CFSTRINGS__ - -CF_EXPORT bool __CFOASafe; -CF_EXPORT void __CFSetLastAllocationEventName(void *ptr, const char *classname); - - - -/* Comparators are passed the address of the values; this is somewhat different than CFComparatorFunction is used in public API usually. */ -CF_EXPORT CFIndex CFBSearch(const void *element, CFIndex elementSize, const void *list, CFIndex count, CFComparatorFunction comparator, void *context); - -CF_EXPORT CFHashCode CFHashBytes(UInt8 *bytes, CFIndex length); - -CF_EXPORT CFStringEncoding CFStringFileSystemEncoding(void); - -CF_PRIVATE CFStringRef __CFStringCreateImmutableFunnel3(CFAllocatorRef alloc, const void *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean possiblyExternalFormat, Boolean tryToReduceUnicode, Boolean hasLengthByte, Boolean hasNullByte, Boolean noCopy, CFAllocatorRef contentsDeallocator, UInt32 converterFlags); - -extern const void *__CFStringCollectionCopy(CFAllocatorRef allocator, const void *ptr); -extern const void *__CFTypeCollectionRetain(CFAllocatorRef allocator, const void *ptr); -extern void __CFTypeCollectionRelease(CFAllocatorRef allocator, const void *ptr); - -extern CFTypeRef CFMakeUncollectable(CFTypeRef cf); - -CF_PRIVATE void _CFRaiseMemoryException(CFStringRef reason); - -CF_PRIVATE Boolean __CFProphylacticAutofsAccess; - - -#if DEPLOYMENT_TARGET_MACOSX - -typedef pthread_mutex_t CFLock_t; - -#define CFLockInit ((pthread_mutex_t)PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) -#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit) - -#define __CFLock(LP) ({ \ - (void)pthread_mutex_lock(LP); }) - -#define __CFUnlock(LP) ({ \ - (void)pthread_mutex_unlock(LP); }) - -#define __CFLockTry(LP) ({ \ - pthread_mutex_trylock(LP) == 0; }) - -#elif DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI - -typedef pthread_mutex_t CFLock_t; - -#define CFLockInit ((pthread_mutex_t)PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) -#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit) - -#define __CFLock(LP) ({ \ - (void)pthread_mutex_lock(LP); }) - -#define __CFUnlock(LP) ({ \ - (void)pthread_mutex_unlock(LP); }) - -#define __CFLockTry(LP) ({ \ - pthread_mutex_trylock(LP) == 0; }) - -#elif DEPLOYMENT_TARGET_WINDOWS - -typedef int32_t CFLock_t; -#define CFLockInit 0 -#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit) - -CF_INLINE void __CFLock(volatile CFLock_t *lock) { - while (InterlockedCompareExchange((LONG volatile *)lock, ~0, 0) != 0) { - Sleep(0); - } -} - -CF_INLINE void __CFUnlock(volatile CFLock_t *lock) { - MemoryBarrier(); - *lock = 0; -} - -CF_INLINE Boolean __CFLockTry(volatile CFLock_t *lock) { - return (InterlockedCompareExchange((LONG volatile *)lock, ~0, 0) == 0); -} - -#elif DEPLOYMENT_TARGET_LINUX - -typedef int32_t CFLock_t; -#define CFLockInit 0 -#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit) - -CF_INLINE void __CFLock(volatile CFLock_t *lock) { - while (__sync_val_compare_and_swap(lock, 0, ~0) != 0) { - sleep(0); - } -} - -CF_INLINE void __CFUnlock(volatile CFLock_t *lock) { - __sync_synchronize(); - *lock = 0; -} - -CF_INLINE Boolean __CFLockTry(volatile CFLock_t *lock) { - return (__sync_val_compare_and_swap(lock, 0, ~0) == 0); -} - -#else - -#warning CF locks not defined for this platform -- CF is not thread-safe -#define __CFLock(A) do {} while (0) -#define __CFUnlock(A) do {} while (0) - -#endif - - -#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI -extern uint8_t __CF120293; -extern uint8_t __CF120290; -extern void __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__(void); -#define CHECK_FOR_FORK() do { __CF120290 = true; if (__CF120293) __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__(); } while (0) -#define CHECK_FOR_FORK_RET(...) do { CHECK_FOR_FORK(); if (__CF120293) return __VA_ARGS__; } while (0) -#define HAS_FORKED() (__CF120293) -#endif - -#if !defined(CHECK_FOR_FORK) -#define CHECK_FOR_FORK() do { } while (0) -#endif - -#if !defined(CHECK_FOR_FORK_RET) -#define CHECK_FOR_FORK_RET(...) do { } while (0) -#endif - -#if !defined(HAS_FORKED) -#define HAS_FORKED() 0 -#endif - -#include - -#define thread_errno() errno -#define thread_set_errno(V) do {errno = (V);} while (0) - -extern void *__CFStartSimpleThread(void *func, void *arg); - -/* ==================== Simple file access ==================== */ -/* For dealing with abstract types. MF:!!! These ought to be somewhere else and public. */ - -CF_EXPORT CFStringRef _CFCopyExtensionForAbstractType(CFStringRef abstractType); - -/* ==================== Simple file access ==================== */ -/* These functions all act on a c-strings which must be in the file system encoding. */ - -CF_PRIVATE Boolean _CFCreateDirectory(const char *path); -CF_PRIVATE Boolean _CFRemoveDirectory(const char *path); -CF_PRIVATE Boolean _CFDeleteFile(const char *path); - -CF_PRIVATE Boolean _CFReadBytesFromFile(CFAllocatorRef alloc, CFURLRef url, void **bytes, CFIndex *length, CFIndex maxLength, int extraOpenFlags); - /* resulting bytes are allocated from alloc which MUST be non-NULL. */ - /* maxLength of zero means the whole file. Otherwise it sets a limit on the number of bytes read. */ - -CF_EXPORT Boolean _CFWriteBytesToFile(CFURLRef url, const void *bytes, CFIndex length); - -CF_PRIVATE CFMutableArrayRef _CFCreateContentsOfDirectory(CFAllocatorRef alloc, char *dirPath, void *dirSpec, CFURLRef dirURL, CFStringRef matchingAbstractType); - /* On Mac OS 8/9, one of dirSpec, dirPath and dirURL must be non-NULL */ - /* On all other platforms, one of path and dirURL must be non-NULL */ - /* If both are present, they are assumed to be in-synch; that is, they both refer to the same directory. */ - /* alloc may be NULL */ - /* return value is CFArray of CFURLs */ - -CF_PRIVATE SInt32 _CFGetPathProperties(CFAllocatorRef alloc, char *path, Boolean *exists, SInt32 *posixMode, SInt64 *size, CFDateRef *modTime, SInt32 *ownerID, CFArrayRef *dirContents); - /* alloc may be NULL */ - /* any of exists, posixMode, size, modTime, and dirContents can be NULL. Usually it is not a good idea to pass NULL for exists, since interpretting the other values sometimes requires that you know whether the file existed or not. Except for dirContents, it is pretty cheap to compute any of these things as loing as one of them must be computed. */ - -CF_PRIVATE SInt32 _CFGetFileProperties(CFAllocatorRef alloc, CFURLRef pathURL, Boolean *exists, SInt32 *posixMode, SInt64 *size, CFDateRef *modTime, SInt32 *ownerID, CFArrayRef *dirContents); - /* alloc may be NULL */ - /* any of exists, posixMode, size, modTime, and dirContents can be NULL. Usually it is not a good idea to pass NULL for exists, since interpretting the other values sometimes requires that you know whether the file existed or not. Except for dirContents, it is pretty cheap to compute any of these things as loing as one of them must be computed. */ - - -/* ==================== Simple path manipulation ==================== */ - -CF_EXPORT UniChar _CFGetSlash(); -CF_PRIVATE CFStringRef _CFGetSlashStr(); -CF_EXPORT Boolean _CFIsAbsolutePath(UniChar *unichars, CFIndex length); -CF_PRIVATE void _CFAppendTrailingPathSlash2(CFMutableStringRef path); -CF_PRIVATE void _CFAppendConditionalTrailingPathSlash2(CFMutableStringRef path); -CF_EXPORT Boolean _CFAppendPathComponent(UniChar *unichars, CFIndex *length, CFIndex maxLength, UniChar *component, CFIndex componentLength); -CF_PRIVATE void _CFAppendPathComponent2(CFMutableStringRef path, CFStringRef component); -CF_PRIVATE Boolean _CFAppendPathExtension2(CFMutableStringRef path, CFStringRef extension); -CF_EXPORT Boolean _CFAppendPathExtension(UniChar *unichars, CFIndex *length, CFIndex maxLength, UniChar *extension, CFIndex extensionLength); -CF_EXPORT Boolean _CFTransmutePathSlashes(UniChar *unichars, CFIndex *length, UniChar replSlash); -CF_PRIVATE CFStringRef _CFCreateLastPathComponent(CFAllocatorRef alloc, CFStringRef path, CFIndex *slashIndex); -CF_EXPORT CFIndex _CFStartOfLastPathComponent(UniChar *unichars, CFIndex length); -CF_PRIVATE CFIndex _CFStartOfLastPathComponent2(CFStringRef path); -CF_EXPORT CFIndex _CFLengthAfterDeletingLastPathComponent(UniChar *unichars, CFIndex length); -CF_PRIVATE CFIndex _CFLengthAfterDeletingPathExtension2(CFStringRef path); -CF_EXPORT CFIndex _CFStartOfPathExtension(UniChar *unichars, CFIndex length); -CF_PRIVATE CFIndex _CFStartOfPathExtension2(CFStringRef path); -CF_EXPORT CFIndex _CFLengthAfterDeletingPathExtension(UniChar *unichars, CFIndex length); - -#if __BLOCKS__ -#if DEPLOYMENT_TARGET_WINDOWS -#define DT_DIR 4 -#define DT_REG 8 -#define DT_LNK 10 -#endif - -// This function automatically skips '.' and '..', and '._' files -CF_PRIVATE void _CFIterateDirectory(CFStringRef directoryPath, Boolean (^fileHandler)(CFStringRef fileName, uint8_t fileType)); -#endif - -#define __CFMaxRuntimeTypes 65535 -#define __CFRuntimeClassTableSize 1024 - -extern void _CFRuntimeSetInstanceTypeIDAndIsa(CFTypeRef cf, CFTypeID newTypeID); - -#define CF_OBJC_FUNCDISPATCHV(typeID, obj, ...) do { } while (0) -#define CF_OBJC_CALLV(obj, ...) (0) -#define CF_IS_OBJC(typeID, obj) (0) -#define __CFISAForTypeID(t) (0) - -/* See comments in CFBase.c -*/ -#define FAULT_CALLBACK(V) -#define INVOKE_CALLBACK1(P, A) (P)(A) -#define INVOKE_CALLBACK2(P, A, B) (P)(A, B) -#define INVOKE_CALLBACK3(P, A, B, C) (P)(A, B, C) -#define INVOKE_CALLBACK4(P, A, B, C, D) (P)(A, B, C, D) -#define INVOKE_CALLBACK5(P, A, B, C, D, E) (P)(A, B, C, D, E) -#define UNFAULT_CALLBACK(V) do { } while (0) - -/* For the support of functionality which needs CarbonCore or other frameworks */ -// These macros define an upcall or weak "symbol-lookup" wrapper function. -// The parameters are: -// R : the return type of the function -// N : the name of the function (in the other library) -// P : the parenthesized parameter list of the function -// A : the parenthesized actual argument list to be passed -// FAILACTION: (only for the _FAIL macros) additional code to be -// run when the function cannot be found. -// opt: a fifth optional argument can be passed in which is the -// return value of the wrapper when the function cannot be -// found; should be of type R, & can be a function call -// The name of the resulting wrapper function is: -// __CFCarbonCore_N (where N is the second parameter) -// __CFNetwork_N (where N is the second parameter) -// -// Example: -// DEFINE_WEAK_CARBONCORE_FUNC(void, DisposeHandle, (Handle h), (h)) -// - -#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED - -extern void *__CFLookupCFNetworkFunction(const char *name); - -#define DEFINE_WEAK_CFNETWORK_FUNC(R, N, P, A, ...) \ - typedef R (*dyfuncptr)P; \ - static dyfuncptr dyfunc = (dyfuncptr)(~(uintptr_t)0); \ - if ((dyfuncptr)(~(uintptr_t)0) == dyfunc) { \ - dyfunc = (dyfuncptr)__CFLookupCFNetworkFunction(#N); } \ - if (dyfunc) { return dyfunc A ; } \ - return __VA_ARGS__ ; \ -} - -#define DEFINE_WEAK_CFNETWORK_FUNC_FAIL(R, N, P, A, FAILACTION, ...) \ -static R __CFNetwork_ ## N P { \ - typedef R (*dyfuncptr)P; \ - static dyfuncptr dyfunc = (dyfuncptr)(~(uintptr_t)0); \ - if ((dyfuncptr)(~(uintptr_t)0) == dyfunc) { \ - dyfunc = (dyfuncptr)__CFLookupCFNetworkFunction(#N); } \ - if (dyfunc) { return dyfunc A ; } \ - FAILACTION ; \ - return __VA_ARGS__ ; \ -} - -#else -#define DEFINE_WEAK_CFNETWORK_FUNC(R, N, P, A, ...) -#define DEFINE_WEAK_CFNETWORK_FUNC_FAIL(R, N, P, A, ...) -#endif - -#define DEFINE_WEAK_CARBONCORE_FUNC(R, N, P, A, ...) - -#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED - -extern void *__CFLookupCoreServicesInternalFunction(const char *name); - -#define DEFINE_WEAK_CORESERVICESINTERNAL_FUNC(R, N, P, A, ...) \ - static R __CFCoreServicesInternal_ ## N P { \ - typedef R (*dyfuncptr)P; \ - static dyfuncptr dyfunc = (dyfuncptr)(~(uintptr_t)0); \ - if ((dyfuncptr)(~(uintptr_t)0) == dyfunc) { \ - dyfunc = (dyfuncptr)__CFLookupCoreServicesInternalFunction(#N); \ - } \ - if (dyfunc) { \ - return dyfunc A ; \ - } \ - return __VA_ARGS__ ; \ - } - -#else -#define DEFINE_WEAK_CORESERVICESINTERNAL_FUNC(R, N, P, A, ...) -#endif - -CF_PRIVATE CFComparisonResult _CFCompareStringsWithLocale(CFStringInlineBuffer *str1, CFRange str1Range, CFStringInlineBuffer *str2, CFRange str2Range, CFOptionFlags options, const void *compareLocale); - - -CF_PRIVATE CFArrayRef _CFBundleCopyUserLanguages(); - - -// This should only be used in CF types, not toll-free bridged objects! -// It should not be used with CFAllocator arguments! -// Use CFGetAllocator() in the general case, and this inline function in a few limited (but often called) situations. -CF_INLINE CFAllocatorRef __CFGetAllocator(CFTypeRef cf) { // !!! Use with CF types only, and NOT WITH CFAllocator! -#if OBJC_HAVE_TAGGED_POINTERS - if (_objc_isTaggedPointer(cf)) { - return kCFAllocatorSystemDefault; - } -#endif - if (__builtin_expect(__CFBitfieldGetValue(((const CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 7, 7), 1)) { - return kCFAllocatorSystemDefault; - } - return *(CFAllocatorRef *)((char *)cf - sizeof(CFAllocatorRef)); -} - -/* !!! Avoid #importing objc.h; e.g. converting this to a .m file */ -struct __objcFastEnumerationStateEquivalent { - unsigned long state; - unsigned long *itemsPtr; - unsigned long *mutationsPtr; - unsigned long extra[5]; -}; - -#if 0 -#pragma mark - -#pragma mark Windows Compatability -#endif - -// Need to use the _O_BINARY flag on Windows to get the correct behavior -#if DEPLOYMENT_TARGET_WINDOWS -#define CF_OPENFLGS (_O_BINARY|_O_NOINHERIT) -#else -#define CF_OPENFLGS (0) -#endif - -#if DEPLOYMENT_TARGET_WINDOWS - -// These are replacements for pthread calls on Windows -CF_EXPORT int _NS_pthread_main_np(); -CF_EXPORT int _NS_pthread_setspecific(pthread_key_t key, const void *val); -CF_EXPORT void* _NS_pthread_getspecific(pthread_key_t key); -CF_EXPORT int _NS_pthread_key_init_np(int key, void (*destructor)(void *)); -CF_EXPORT void _NS_pthread_setname_np(const char *name); - -// map use of pthread_set/getspecific to internal API -#define pthread_setspecific _NS_pthread_setspecific -#define pthread_getspecific _NS_pthread_getspecific -#define pthread_key_init_np _NS_pthread_key_init_np -#define pthread_main_np _NS_pthread_main_np -#define pthread_setname_np _NS_pthread_setname_np -#endif - -#if DEPLOYMENT_TARGET_WINDOWS -// replacement for DISPATCH_QUEUE_OVERCOMMIT until we get a bug fix in dispatch on Windows -// dispatch on Windows: Need queue_private.h -#define DISPATCH_QUEUE_OVERCOMMIT 2 -#endif - -#if DEPLOYMENT_TARGET_WINDOWS -CF_PRIVATE const wchar_t *_CFDLLPath(void); -#endif - -/* Buffer size for file pathname */ -#if DEPLOYMENT_TARGET_WINDOWS -#define CFMaxPathSize ((CFIndex)262) -#define CFMaxPathLength ((CFIndex)260) -#define PATH_SEP '\\' -#define PATH_SEP_STR CFSTR("\\") -#define PATH_MAX MAX_PATH -#else -#define CFMaxPathSize ((CFIndex)1026) -#define CFMaxPathLength ((CFIndex)1024) -#define PATH_SEP '/' -#define PATH_SEP_STR CFSTR("/") -#endif - -CF_INLINE const char *CFPathRelativeToAppleFrameworksRoot(const char *path, Boolean *allocated) { - if (path) { - const char *platformRoot = __CFgetenv("APPLE_FRAMEWORKS_ROOT"); - if (platformRoot) { - char *newPath = NULL; - asprintf(&newPath, "%s%s", platformRoot, path); - if (allocated && newPath) { - *allocated = true; - } - return newPath; - } - } - if (allocated) { - *allocated = false; - } - return path; -} - -#include -#include - -#if (DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED) - -// Returns a generic dispatch queue for when you want to just throw some work -// into the concurrent pile to execute, and don't care about specifics except -// to match the QOS of the main thread. -CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericMatchingMain(void) { - return dispatch_get_global_queue(qos_class_main(), DISPATCH_QUEUE_OVERCOMMIT); -} - -// Returns a generic dispatch queue for when you want to just throw some work -// into the concurrent pile to execute, and don't care about specifics except -// to match the QOS of the current thread. -CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericMatchingCurrent(void) { - return dispatch_get_global_queue(qos_class_self(), 0); // DISPATCH_QUEUE_OVERCOMMIT left out intentionally at this point -} - -// Returns a generic dispatch queue for when you want to just throw some work -// into the concurrent pile to execute, and don't care about specifics except -// that it should be in background QOS. -CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericBackground(void) { - // Don't ACTUALLY use BACKGROUND, because of unknowable and unfavorable interactions like () - return dispatch_get_global_queue(QOS_CLASS_UTILITY, DISPATCH_QUEUE_OVERCOMMIT); -} - -#else - -CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericMatchingMain(void) { - return dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, DISPATCH_QUEUE_OVERCOMMIT); -} - -CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericMatchingCurrent(void) { - return dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0); // DISPATCH_QUEUE_OVERCOMMIT left out intentionally at this point -} - -CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericBackground(void) { - return dispatch_get_global_queue(QOS_CLASS_UTILITY, DISPATCH_QUEUE_OVERCOMMIT); -} - -#endif - - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFINTERNAL__ */ - diff --git a/CFInternal.h b/CFInternal.h new file mode 120000 index 0000000..873cd01 --- /dev/null +++ b/CFInternal.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFInternal.h \ No newline at end of file diff --git a/CFLocale.h b/CFLocale.h deleted file mode 100644 index cf7010f..0000000 --- a/CFLocale.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFLocale.h - Copyright (c) 2002-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFLOCALE__) -#define __COREFOUNDATION_CFLOCALE__ 1 - -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef const struct CF_BRIDGED_TYPE(NSLocale) __CFLocale *CFLocaleRef; - -CF_EXPORT -CFTypeID CFLocaleGetTypeID(void); - -CF_EXPORT -CFLocaleRef CFLocaleGetSystem(void); - // Returns the "root", canonical locale. Contains fixed "backstop" settings. - -CF_EXPORT -CFLocaleRef CFLocaleCopyCurrent(void); - // Returns the logical "user" locale for the current user. - // [This is Copy in the sense that you get a retain you have to release, - // but we may return the same cached object over and over.] Settings - // you get from this locale do not change under you as CFPreferences - // are changed (for safety and correctness). Generally you would not - // grab this and hold onto it forever, but use it to do the operations - // you need to do at the moment, then throw it away. (The non-changing - // ensures that all the results of your operations are consistent.) - -CF_EXPORT -CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void); - // Returns an array of CFStrings that represents all locales for - // which locale data is available. - -CF_EXPORT -CFArrayRef CFLocaleCopyISOLanguageCodes(void); - // Returns an array of CFStrings that represents all known legal ISO - // language codes. Note: many of these will not have any supporting - // locale data in Mac OS X. - -CF_EXPORT -CFArrayRef CFLocaleCopyISOCountryCodes(void); - // Returns an array of CFStrings that represents all known legal ISO - // country codes. Note: many of these will not have any supporting - // locale data in Mac OS X. - -CF_EXPORT -CFArrayRef CFLocaleCopyISOCurrencyCodes(void); - // Returns an array of CFStrings that represents all known legal ISO - // currency codes. Note: some of these currencies may be obsolete, or - // represent other financial instruments. - -CF_EXPORT -CFArrayRef CFLocaleCopyCommonISOCurrencyCodes(void) CF_AVAILABLE(10_5, 2_0); - // Returns an array of CFStrings that represents ISO currency codes for - // currencies in common use. - -CF_EXPORT -CFArrayRef CFLocaleCopyPreferredLanguages(void) CF_AVAILABLE(10_5, 2_0); - // Returns the array of canonicalized CFString locale IDs that the user prefers. - -CF_EXPORT -CFStringRef CFLocaleCreateCanonicalLanguageIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier); - // Map an arbitrary language identification string (something close at - // least) to a canonical language identifier. - -CF_EXPORT -CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier); - // Map an arbitrary locale identification string (something close at - // least) to the canonical identifier. - -CF_EXPORT -CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(CFAllocatorRef allocator, LangCode lcode, RegionCode rcode); - // Map a Mac OS LangCode and RegionCode to the canonical locale identifier. - -CF_EXPORT -CFStringRef CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode(CFAllocatorRef allocator, uint32_t lcid) CF_AVAILABLE(10_6, 4_0); - // Map a Windows LCID to the canonical locale identifier. - -CF_EXPORT -uint32_t CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier(CFStringRef localeIdentifier) CF_AVAILABLE(10_6, 4_0); - // Map a locale identifier to a Windows LCID. - -typedef CF_ENUM(CFIndex, CFLocaleLanguageDirection) { - kCFLocaleLanguageDirectionUnknown = 0, - kCFLocaleLanguageDirectionLeftToRight = 1, - kCFLocaleLanguageDirectionRightToLeft = 2, - kCFLocaleLanguageDirectionTopToBottom = 3, - kCFLocaleLanguageDirectionBottomToTop = 4 -}; - -CF_EXPORT -CFLocaleLanguageDirection CFLocaleGetLanguageCharacterDirection(CFStringRef isoLangCode) CF_AVAILABLE(10_6, 4_0); - -CF_EXPORT -CFLocaleLanguageDirection CFLocaleGetLanguageLineDirection(CFStringRef isoLangCode) CF_AVAILABLE(10_6, 4_0); - -CF_EXPORT -CFDictionaryRef CFLocaleCreateComponentsFromLocaleIdentifier(CFAllocatorRef allocator, CFStringRef localeID); - // Parses a locale ID consisting of language, script, country, variant, - // and keyword/value pairs into a dictionary. The keys are the constant - // CFStrings corresponding to the locale ID components, and the values - // will correspond to constants where available. - // Example: "en_US@calendar=japanese" yields a dictionary with three - // entries: kCFLocaleLanguageCode=en, kCFLocaleCountryCode=US, and - // kCFLocaleCalendarIdentifier=kCFJapaneseCalendar. - -CF_EXPORT -CFStringRef CFLocaleCreateLocaleIdentifierFromComponents(CFAllocatorRef allocator, CFDictionaryRef dictionary); - // Reverses the actions of CFLocaleCreateDictionaryFromLocaleIdentifier, - // creating a single string from the data in the dictionary. The - // dictionary {kCFLocaleLanguageCode=en, kCFLocaleCountryCode=US, - // kCFLocaleCalendarIdentifier=kCFJapaneseCalendar} becomes - // "en_US@calendar=japanese". - -CF_EXPORT -CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator, CFStringRef localeIdentifier); - // Returns a CFLocaleRef for the locale named by the "arbitrary" locale identifier. - -CF_EXPORT -CFLocaleRef CFLocaleCreateCopy(CFAllocatorRef allocator, CFLocaleRef locale); - // Having gotten a CFLocale from somebody, code should make a copy - // if it is going to use it for several operations - // or hold onto it. In the future, there may be mutable locales. - -CF_EXPORT -CFStringRef CFLocaleGetIdentifier(CFLocaleRef locale); - // Returns the locale's identifier. This may not be the same string - // that the locale was created with (CFLocale may canonicalize it). - -CF_EXPORT -CFTypeRef CFLocaleGetValue(CFLocaleRef locale, CFStringRef key); - // Returns the value for the given key. This is how settings and state - // are accessed via a CFLocale. Values might be of any CF type. - -CF_EXPORT -CFStringRef CFLocaleCopyDisplayNameForPropertyValue(CFLocaleRef displayLocale, CFStringRef key, CFStringRef value); - // Returns the display name for the given value. The key tells what - // the value is, and is one of the usual locale property keys, though - // not all locale property keys have values with display name values. - - -CF_EXPORT const CFStringRef kCFLocaleCurrentLocaleDidChangeNotification CF_AVAILABLE(10_5, 2_0); - - -// Locale Keys -CF_EXPORT const CFStringRef kCFLocaleIdentifier; -CF_EXPORT const CFStringRef kCFLocaleLanguageCode; -CF_EXPORT const CFStringRef kCFLocaleCountryCode; -CF_EXPORT const CFStringRef kCFLocaleScriptCode; -CF_EXPORT const CFStringRef kCFLocaleVariantCode; - -CF_EXPORT const CFStringRef kCFLocaleExemplarCharacterSet; -CF_EXPORT const CFStringRef kCFLocaleCalendarIdentifier; -CF_EXPORT const CFStringRef kCFLocaleCalendar; -CF_EXPORT const CFStringRef kCFLocaleCollationIdentifier; -CF_EXPORT const CFStringRef kCFLocaleUsesMetricSystem; -CF_EXPORT const CFStringRef kCFLocaleMeasurementSystem; // "Metric" or "U.S." -CF_EXPORT const CFStringRef kCFLocaleDecimalSeparator; -CF_EXPORT const CFStringRef kCFLocaleGroupingSeparator; -CF_EXPORT const CFStringRef kCFLocaleCurrencySymbol; -CF_EXPORT const CFStringRef kCFLocaleCurrencyCode; // ISO 3-letter currency code -CF_EXPORT const CFStringRef kCFLocaleCollatorIdentifier CF_AVAILABLE(10_6, 4_0); -CF_EXPORT const CFStringRef kCFLocaleQuotationBeginDelimiterKey CF_AVAILABLE(10_6, 4_0); -CF_EXPORT const CFStringRef kCFLocaleQuotationEndDelimiterKey CF_AVAILABLE(10_6, 4_0); -CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationBeginDelimiterKey CF_AVAILABLE(10_6, 4_0); -CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationEndDelimiterKey CF_AVAILABLE(10_6, 4_0); - -// Values for kCFLocaleCalendarIdentifier -CF_EXPORT const CFStringRef kCFGregorianCalendar; -CF_EXPORT const CFStringRef kCFBuddhistCalendar; -CF_EXPORT const CFStringRef kCFChineseCalendar; -CF_EXPORT const CFStringRef kCFHebrewCalendar; -CF_EXPORT const CFStringRef kCFIslamicCalendar; -CF_EXPORT const CFStringRef kCFIslamicCivilCalendar; -CF_EXPORT const CFStringRef kCFJapaneseCalendar; -CF_EXPORT const CFStringRef kCFRepublicOfChinaCalendar CF_AVAILABLE(10_6, 4_0); -CF_EXPORT const CFStringRef kCFPersianCalendar CF_AVAILABLE(10_6, 4_0); -CF_EXPORT const CFStringRef kCFIndianCalendar CF_AVAILABLE(10_6, 4_0); -CF_EXPORT const CFStringRef kCFISO8601Calendar CF_AVAILABLE(10_6, 4_0); -CF_EXPORT const CFStringRef kCFIslamicTabularCalendar CF_AVAILABLE(10_10, 8_0); -CF_EXPORT const CFStringRef kCFIslamicUmmAlQuraCalendar CF_AVAILABLE(10_10, 8_0); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFLOCALE__ */ - diff --git a/CFLocale.h b/CFLocale.h new file mode 120000 index 0000000..ec4d161 --- /dev/null +++ b/CFLocale.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFLocale.h \ No newline at end of file diff --git a/CFLocaleInternal.h b/CFLocaleInternal.h deleted file mode 100644 index fa17aa0..0000000 --- a/CFLocaleInternal.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* - CFLocaleInternal.h - Copyright (c) 2008-2014, Apple Inc. All rights reserved. - */ - -/* - This file is for the use of the CoreFoundation project only. - */ - -#include - -CF_EXPORT CFStringRef const kCFLocaleAlternateQuotationBeginDelimiterKey; -CF_EXPORT CFStringRef const kCFLocaleAlternateQuotationEndDelimiterKey; -CF_EXPORT CFStringRef const kCFLocaleQuotationBeginDelimiterKey; -CF_EXPORT CFStringRef const kCFLocaleQuotationEndDelimiterKey; -CF_EXPORT CFStringRef const kCFLocaleCalendarIdentifierKey; // *** -CF_EXPORT CFStringRef const kCFLocaleCalendarKey; -CF_EXPORT CFStringRef const kCFLocaleCollationIdentifierKey; // *** -CF_EXPORT CFStringRef const kCFLocaleCollatorIdentifierKey; -CF_EXPORT CFStringRef const kCFLocaleCountryCodeKey; -CF_EXPORT CFStringRef const kCFLocaleCurrencyCodeKey; // *** -CF_EXPORT CFStringRef const kCFLocaleCurrencySymbolKey; -CF_EXPORT CFStringRef const kCFLocaleDecimalSeparatorKey; -CF_EXPORT CFStringRef const kCFLocaleExemplarCharacterSetKey; -CF_EXPORT CFStringRef const kCFLocaleGroupingSeparatorKey; -CF_EXPORT CFStringRef const kCFLocaleIdentifierKey; -CF_EXPORT CFStringRef const kCFLocaleLanguageCodeKey; -CF_EXPORT CFStringRef const kCFLocaleMeasurementSystemKey; -CF_EXPORT CFStringRef const kCFLocaleScriptCodeKey; -CF_EXPORT CFStringRef const kCFLocaleUsesMetricSystemKey; -CF_EXPORT CFStringRef const kCFLocaleVariantCodeKey; - -CF_EXPORT CFStringRef const kCFDateFormatterAMSymbolKey; -CF_EXPORT CFStringRef const kCFDateFormatterCalendarKey; -CF_EXPORT CFStringRef const kCFDateFormatterCalendarIdentifierKey; -CF_EXPORT CFStringRef const kCFDateFormatterDefaultDateKey; -CF_EXPORT CFStringRef const kCFDateFormatterDefaultFormatKey; -CF_EXPORT CFStringRef const kCFDateFormatterDoesRelativeDateFormattingKey; -CF_EXPORT CFStringRef const kCFDateFormatterEraSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterGregorianStartDateKey; -CF_EXPORT CFStringRef const kCFDateFormatterIsLenientKey; -CF_EXPORT CFStringRef const kCFDateFormatterLongEraSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterMonthSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterPMSymbolKey; -CF_EXPORT CFStringRef const kCFDateFormatterAmbiguousYearStrategyKey; -CF_EXPORT CFStringRef const kCFDateFormatterQuarterSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterShortMonthSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterShortQuarterSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterShortStandaloneMonthSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterShortStandaloneQuarterSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterShortStandaloneWeekdaySymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterShortWeekdaySymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterStandaloneMonthSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterStandaloneQuarterSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterStandaloneWeekdaySymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterTimeZoneKey; -CF_EXPORT CFStringRef const kCFDateFormatterTwoDigitStartDateKey; -CF_EXPORT CFStringRef const kCFDateFormatterVeryShortMonthSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterVeryShortStandaloneMonthSymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterVeryShortStandaloneWeekdaySymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterVeryShortWeekdaySymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterWeekdaySymbolsKey; -CF_EXPORT CFStringRef const kCFDateFormatterUsesCharacterDirectionKey; - -CF_EXPORT CFStringRef const kCFNumberFormatterAlwaysShowDecimalSeparatorKey; -CF_EXPORT CFStringRef const kCFNumberFormatterCurrencyCodeKey; -CF_EXPORT CFStringRef const kCFNumberFormatterCurrencyDecimalSeparatorKey; -CF_EXPORT CFStringRef const kCFNumberFormatterCurrencyGroupingSeparatorKey; -CF_EXPORT CFStringRef const kCFNumberFormatterCurrencySymbolKey; -CF_EXPORT CFStringRef const kCFNumberFormatterDecimalSeparatorKey; -CF_EXPORT CFStringRef const kCFNumberFormatterDefaultFormatKey; -CF_EXPORT CFStringRef const kCFNumberFormatterExponentSymbolKey; -CF_EXPORT CFStringRef const kCFNumberFormatterFormatWidthKey; -CF_EXPORT CFStringRef const kCFNumberFormatterGroupingSeparatorKey; -CF_EXPORT CFStringRef const kCFNumberFormatterGroupingSizeKey; -CF_EXPORT CFStringRef const kCFNumberFormatterInfinitySymbolKey; -CF_EXPORT CFStringRef const kCFNumberFormatterInternationalCurrencySymbolKey; -CF_EXPORT CFStringRef const kCFNumberFormatterIsLenientKey; -CF_EXPORT CFStringRef const kCFNumberFormatterMaxFractionDigitsKey; -CF_EXPORT CFStringRef const kCFNumberFormatterMaxIntegerDigitsKey; -CF_EXPORT CFStringRef const kCFNumberFormatterMaxSignificantDigitsKey; -CF_EXPORT CFStringRef const kCFNumberFormatterMinFractionDigitsKey; -CF_EXPORT CFStringRef const kCFNumberFormatterMinIntegerDigitsKey; -CF_EXPORT CFStringRef const kCFNumberFormatterMinSignificantDigitsKey; -CF_EXPORT CFStringRef const kCFNumberFormatterMinusSignKey; -CF_EXPORT CFStringRef const kCFNumberFormatterMultiplierKey; -CF_EXPORT CFStringRef const kCFNumberFormatterNaNSymbolKey; -CF_EXPORT CFStringRef const kCFNumberFormatterNegativePrefixKey; -CF_EXPORT CFStringRef const kCFNumberFormatterNegativeSuffixKey; -CF_EXPORT CFStringRef const kCFNumberFormatterPaddingCharacterKey; -CF_EXPORT CFStringRef const kCFNumberFormatterPaddingPositionKey; -CF_EXPORT CFStringRef const kCFNumberFormatterPerMillSymbolKey; -CF_EXPORT CFStringRef const kCFNumberFormatterPercentSymbolKey; -CF_EXPORT CFStringRef const kCFNumberFormatterPlusSignKey; -CF_EXPORT CFStringRef const kCFNumberFormatterPositivePrefixKey; -CF_EXPORT CFStringRef const kCFNumberFormatterPositiveSuffixKey; -CF_EXPORT CFStringRef const kCFNumberFormatterRoundingIncrementKey; -CF_EXPORT CFStringRef const kCFNumberFormatterRoundingModeKey; -CF_EXPORT CFStringRef const kCFNumberFormatterSecondaryGroupingSizeKey; -CF_EXPORT CFStringRef const kCFNumberFormatterUseGroupingSeparatorKey; -CF_EXPORT CFStringRef const kCFNumberFormatterUseSignificantDigitsKey; -CF_EXPORT CFStringRef const kCFNumberFormatterZeroSymbolKey; -CF_EXPORT CFStringRef const kCFNumberFormatterUsesCharacterDirectionKey; - -CF_EXPORT CFStringRef const kCFCalendarIdentifierGregorian; -CF_EXPORT CFStringRef const kCFCalendarIdentifierBuddhist; -CF_EXPORT CFStringRef const kCFCalendarIdentifierJapanese; -CF_EXPORT CFStringRef const kCFCalendarIdentifierIslamic; -CF_EXPORT CFStringRef const kCFCalendarIdentifierIslamicCivil; -CF_EXPORT CFStringRef const kCFCalendarIdentifierIslamicTabular; -CF_EXPORT CFStringRef const kCFCalendarIdentifierIslamicUmmAlQura; -CF_EXPORT CFStringRef const kCFCalendarIdentifierHebrew; -CF_EXPORT CFStringRef const kCFCalendarIdentifierChinese; -CF_EXPORT CFStringRef const kCFCalendarIdentifierRepublicOfChina; -CF_EXPORT CFStringRef const kCFCalendarIdentifierPersian; -CF_EXPORT CFStringRef const kCFCalendarIdentifierIndian; -CF_EXPORT CFStringRef const kCFCalendarIdentifierISO8601; -CF_EXPORT CFStringRef const kCFCalendarIdentifierCoptic; -CF_EXPORT CFStringRef const kCFCalendarIdentifierEthiopicAmeteMihret; -CF_EXPORT CFStringRef const kCFCalendarIdentifierEthiopicAmeteAlem; - - diff --git a/CFLocaleInternal.h b/CFLocaleInternal.h new file mode 120000 index 0000000..317d315 --- /dev/null +++ b/CFLocaleInternal.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFLocaleInternal.h \ No newline at end of file diff --git a/CFLogUtilities.h b/CFLogUtilities.h deleted file mode 100644 index 694a931..0000000 --- a/CFLogUtilities.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFLogUtilities.h - Copyright (c) 2004-2014, Apple Inc. All rights reserved. -*/ - -/* - APPLE SPI: NOT TO BE USED OUTSIDE APPLE! -*/ - -#if !defined(__COREFOUNDATION_CFLOGUTILITIES__) -#define __COREFOUNDATION_CFLOGUTILITIES__ 1 - -#include -#include - -CF_EXTERN_C_BEGIN - - -enum { // Legal level values for CFLog() - kCFLogLevelEmergency = 0, - kCFLogLevelAlert = 1, - kCFLogLevelCritical = 2, - kCFLogLevelError = 3, - kCFLogLevelWarning = 4, - kCFLogLevelNotice = 5, - kCFLogLevelInfo = 6, - kCFLogLevelDebug = 7, -}; - -CF_EXPORT void CFLog(int32_t level, CFStringRef format, ...); -/* Passing in a level value which is outside the range of 0-7 will cause the the call to do nothing. - CFLog() logs the message using the asl.h API, and uses the level parameter as the log level. - Note that the asl subsystem ignores some log levels by default. - CFLog() is not fast, and is not going to be guaranteed to be fast. - Even "no-op" CFLogs are not necessarily fast. - If you care about performance, you shouldn't be logging. -*/ - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFLOGUTILITIES__ */ - diff --git a/CFLogUtilities.h b/CFLogUtilities.h new file mode 120000 index 0000000..8c5da20 --- /dev/null +++ b/CFLogUtilities.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFLogUtilities.h \ No newline at end of file diff --git a/CFMachPort.h b/CFMachPort.h deleted file mode 100644 index 40d15ab..0000000 --- a/CFMachPort.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFMachPort.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFMACHPORT__) -#define __COREFOUNDATION_CFMACHPORT__ 1 - -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMachPort) __CFMachPort * CFMachPortRef; - -typedef struct { - CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); -} CFMachPortContext; - -typedef void (*CFMachPortCallBack)(CFMachPortRef port, void *msg, CFIndex size, void *info); -typedef void (*CFMachPortInvalidationCallBack)(CFMachPortRef port, void *info); - -CF_EXPORT CFTypeID CFMachPortGetTypeID(void); - -CF_EXPORT CFMachPortRef CFMachPortCreate(CFAllocatorRef allocator, CFMachPortCallBack callout, CFMachPortContext *context, Boolean *shouldFreeInfo); -CF_EXPORT CFMachPortRef CFMachPortCreateWithPort(CFAllocatorRef allocator, mach_port_t portNum, CFMachPortCallBack callout, CFMachPortContext *context, Boolean *shouldFreeInfo); - -CF_EXPORT mach_port_t CFMachPortGetPort(CFMachPortRef port); -CF_EXPORT void CFMachPortGetContext(CFMachPortRef port, CFMachPortContext *context); -CF_EXPORT void CFMachPortInvalidate(CFMachPortRef port); -CF_EXPORT Boolean CFMachPortIsValid(CFMachPortRef port); -CF_EXPORT CFMachPortInvalidationCallBack CFMachPortGetInvalidationCallBack(CFMachPortRef port); -CF_EXPORT void CFMachPortSetInvalidationCallBack(CFMachPortRef port, CFMachPortInvalidationCallBack callout); - -CF_EXPORT CFRunLoopSourceRef CFMachPortCreateRunLoopSource(CFAllocatorRef allocator, CFMachPortRef port, CFIndex order); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFMACHPORT__ */ - diff --git a/CFMachPort.h b/CFMachPort.h new file mode 120000 index 0000000..4811fd6 --- /dev/null +++ b/CFMachPort.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFMachPort.h \ No newline at end of file diff --git a/CFMessagePort.h b/CFMessagePort.h deleted file mode 100644 index a4aa040..0000000 --- a/CFMessagePort.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFMessagePort.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFMESSAGEPORT__) -#define __COREFOUNDATION_CFMESSAGEPORT__ 1 - -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMessagePort) __CFMessagePort * CFMessagePortRef; - -enum { - kCFMessagePortSuccess = 0, - kCFMessagePortSendTimeout = -1, - kCFMessagePortReceiveTimeout = -2, - kCFMessagePortIsInvalid = -3, - kCFMessagePortTransportError = -4, - kCFMessagePortBecameInvalidError = -5 -}; - -typedef struct { - CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); -} CFMessagePortContext; - -typedef CFDataRef (*CFMessagePortCallBack)(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info); -/* 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. */ -typedef void (*CFMessagePortInvalidationCallBack)(CFMessagePortRef ms, void *info); - -CF_EXPORT CFTypeID CFMessagePortGetTypeID(void); - -CF_EXPORT CFMessagePortRef CFMessagePortCreateLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo); -CF_EXPORT CFMessagePortRef CFMessagePortCreateRemote(CFAllocatorRef allocator, CFStringRef name); - -CF_EXPORT Boolean CFMessagePortIsRemote(CFMessagePortRef ms); -CF_EXPORT CFStringRef CFMessagePortGetName(CFMessagePortRef ms); -CF_EXPORT Boolean CFMessagePortSetName(CFMessagePortRef ms, CFStringRef newName); -CF_EXPORT void CFMessagePortGetContext(CFMessagePortRef ms, CFMessagePortContext *context); -CF_EXPORT void CFMessagePortInvalidate(CFMessagePortRef ms); -CF_EXPORT Boolean CFMessagePortIsValid(CFMessagePortRef ms); -CF_EXPORT CFMessagePortInvalidationCallBack CFMessagePortGetInvalidationCallBack(CFMessagePortRef ms); -CF_EXPORT void CFMessagePortSetInvalidationCallBack(CFMessagePortRef ms, CFMessagePortInvalidationCallBack callout); - -/* NULL replyMode argument means no return value expected, dont wait for it */ -CF_EXPORT SInt32 CFMessagePortSendRequest(CFMessagePortRef remote, SInt32 msgid, CFDataRef data, CFTimeInterval sendTimeout, CFTimeInterval rcvTimeout, CFStringRef replyMode, CFDataRef *returnData); - -CF_EXPORT CFRunLoopSourceRef CFMessagePortCreateRunLoopSource(CFAllocatorRef allocator, CFMessagePortRef local, CFIndex order); - -CF_EXPORT void CFMessagePortSetDispatchQueue(CFMessagePortRef ms, dispatch_queue_t queue) CF_AVAILABLE(10_6, 4_0); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFMESSAGEPORT__ */ - diff --git a/CFMessagePort.h b/CFMessagePort.h new file mode 120000 index 0000000..08c362d --- /dev/null +++ b/CFMessagePort.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFMessagePort.h \ No newline at end of file diff --git a/CFNotificationCenter.h b/CFNotificationCenter.h deleted file mode 100644 index 28ccabd..0000000 --- a/CFNotificationCenter.h +++ /dev/null @@ -1,37 +0,0 @@ -#if !defined(__COREFOUNDATION_CFNOTIFICATIONCENTER__) -#define __COREFOUNDATION_CFNOTIFICATIONCENTER__ 1 - -#include -#include - -CF_EXTERN_C_BEGIN - -typedef struct __CFNotificationCenter * CFNotificationCenterRef; - -typedef void (*CFNotificationCallback)(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo); - -typedef CF_ENUM(CFIndex, CFNotificationSuspensionBehavior) { - CFNotificationSuspensionBehaviorDrop = 1, - CFNotificationSuspensionBehaviorCoalesce = 2, - CFNotificationSuspensionBehaviorHold = 3, - CFNotificationSuspensionBehaviorDeliverImmediately = 4 -}; - -enum { - kCFNotificationDeliverImmediately = (1UL << 0), - kCFNotificationPostToAllSessions = (1UL << 1) -}; - -CF_EXPORT CFTypeID CFNotificationCenterGetTypeID(void); -CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetLocalCenter(void); -CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetDarwinNotifyCenter(void); -CF_EXPORT void CFNotificationCenterAddObserver(CFNotificationCenterRef center, const void *observer, CFNotificationCallback callBack, CFStringRef name, const void *object, CFNotificationSuspensionBehavior suspensionBehavior); -CF_EXPORT void CFNotificationCenterRemoveObserver(CFNotificationCenterRef center, const void *observer, CFStringRef name, const void *object); -CF_EXPORT void CFNotificationCenterRemoveEveryObserver(CFNotificationCenterRef center, const void *observer); -CF_EXPORT void CFNotificationCenterPostNotification(CFNotificationCenterRef center, CFStringRef name, const void *object, CFDictionaryRef userInfo, Boolean deliverImmediately); -CF_EXPORT void CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterRef center, CFStringRef name, const void *object, CFDictionaryRef userInfo, CFOptionFlags options); - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFNOTIFICATIONCENTER__ */ - diff --git a/CFNotificationCenter.h b/CFNotificationCenter.h new file mode 120000 index 0000000..d93a05b --- /dev/null +++ b/CFNotificationCenter.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFNotificationCenter.h \ No newline at end of file diff --git a/CFNumber.h b/CFNumber.h deleted file mode 100644 index e975113..0000000 --- a/CFNumber.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFNumber.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFNUMBER__) -#define __COREFOUNDATION_CFNUMBER__ 1 - -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef const struct CF_BRIDGED_TYPE(NSNumber) __CFBoolean * CFBooleanRef; - -CF_EXPORT -const CFBooleanRef kCFBooleanTrue; -CF_EXPORT -const CFBooleanRef kCFBooleanFalse; - -CF_EXPORT -CFTypeID CFBooleanGetTypeID(void); - -CF_EXPORT -Boolean CFBooleanGetValue(CFBooleanRef boolean); - -typedef CF_ENUM(CFIndex, CFNumberType) { - /* Fixed-width types */ - kCFNumberSInt8Type = 1, - kCFNumberSInt16Type = 2, - kCFNumberSInt32Type = 3, - kCFNumberSInt64Type = 4, - kCFNumberFloat32Type = 5, - kCFNumberFloat64Type = 6, /* 64-bit IEEE 754 */ - /* Basic C types */ - kCFNumberCharType = 7, - kCFNumberShortType = 8, - kCFNumberIntType = 9, - kCFNumberLongType = 10, - kCFNumberLongLongType = 11, - kCFNumberFloatType = 12, - kCFNumberDoubleType = 13, - /* Other */ - kCFNumberCFIndexType = 14, - kCFNumberNSIntegerType CF_ENUM_AVAILABLE(10_5, 2_0) = 15, - kCFNumberCGFloatType CF_ENUM_AVAILABLE(10_5, 2_0) = 16, - kCFNumberMaxType = 16 -}; - -typedef const struct CF_BRIDGED_TYPE(NSNumber) __CFNumber * CFNumberRef; - -CF_EXPORT -const CFNumberRef kCFNumberPositiveInfinity; -CF_EXPORT -const CFNumberRef kCFNumberNegativeInfinity; -CF_EXPORT -const CFNumberRef kCFNumberNaN; - -CF_EXPORT -CFTypeID CFNumberGetTypeID(void); - -/* - Creates a CFNumber with the given value. The type of number pointed - to by the valuePtr is specified by type. If type is a floating point - type and the value represents one of the infinities or NaN, the - well-defined CFNumber for that value is returned. If either of - valuePtr or type is an invalid value, the result is undefined. -*/ -CF_EXPORT -CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr); - -/* - Returns the storage format of the CFNumber's value. Note that - this is not necessarily the type provided in CFNumberCreate(). -*/ -CF_EXPORT -CFNumberType CFNumberGetType(CFNumberRef number); - -/* - Returns the size in bytes of the type of the number. -*/ -CF_EXPORT -CFIndex CFNumberGetByteSize(CFNumberRef number); - -/* - Returns true if the type of the CFNumber's value is one of - the defined floating point types. -*/ -CF_EXPORT -Boolean CFNumberIsFloatType(CFNumberRef number); - -/* - Copies the CFNumber's value into the space pointed to by - valuePtr, as the specified type. If conversion needs to take - place, the conversion rules follow human expectation and not - C's promotion and truncation rules. If the conversion is - lossy, or the value is out of range, false is returned. Best - attempt at conversion will still be in *valuePtr. -*/ -CF_EXPORT -Boolean CFNumberGetValue(CFNumberRef number, CFNumberType theType, void *valuePtr); - -/* - Compares the two CFNumber instances. If conversion of the - types of the values is needed, the conversion and comparison - follow human expectations and not C's promotion and comparison - rules. Negative zero compares less than positive zero. - Positive infinity compares greater than everything except - itself, to which it compares equal. Negative infinity compares - less than everything except itself, to which it compares equal. - Unlike standard practice, if both numbers are NaN, then they - compare equal; if only one of the numbers is NaN, then the NaN - compares greater than the other number if it is negative, and - smaller than the other number if it is positive. (Note that in - CFEqual() with two CFNumbers, if either or both of the numbers - is NaN, true is returned.) -*/ -CF_EXPORT -CFComparisonResult CFNumberCompare(CFNumberRef number, CFNumberRef otherNumber, void *context); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFNUMBER__ */ - diff --git a/CFNumber.h b/CFNumber.h new file mode 120000 index 0000000..5615c3f --- /dev/null +++ b/CFNumber.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFNumber.h \ No newline at end of file diff --git a/CFNumberFormatter.h b/CFNumberFormatter.h deleted file mode 100644 index 2c3a6e4..0000000 --- a/CFNumberFormatter.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFNumberFormatter.h - Copyright (c) 2003-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFNUMBERFORMATTER__) -#define __COREFOUNDATION_CFNUMBERFORMATTER__ 1 - -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct __CFNumberFormatter *CFNumberFormatterRef; - -// CFNumberFormatters are not thread-safe. Do not use one from multiple threads! - -CF_EXPORT -CFTypeID CFNumberFormatterGetTypeID(void); - -typedef CF_ENUM(CFIndex, CFNumberFormatterStyle) { // number format styles - kCFNumberFormatterNoStyle = 0, - kCFNumberFormatterDecimalStyle = 1, - kCFNumberFormatterCurrencyStyle = 2, - kCFNumberFormatterPercentStyle = 3, - kCFNumberFormatterScientificStyle = 4, - kCFNumberFormatterSpellOutStyle = 5 -}; - - -CF_EXPORT -CFNumberFormatterRef CFNumberFormatterCreate(CFAllocatorRef allocator, CFLocaleRef locale, CFNumberFormatterStyle style); - // Returns a CFNumberFormatter, localized to the given locale, which - // will format numbers to the given style. - -CF_EXPORT -CFLocaleRef CFNumberFormatterGetLocale(CFNumberFormatterRef formatter); - -CF_EXPORT -CFNumberFormatterStyle CFNumberFormatterGetStyle(CFNumberFormatterRef formatter); - // Get the properties with which the number formatter was created. - -CF_EXPORT -CFStringRef CFNumberFormatterGetFormat(CFNumberFormatterRef formatter); - -CF_EXPORT -void CFNumberFormatterSetFormat(CFNumberFormatterRef formatter, CFStringRef formatString); - // Set the format description string of the number formatter. This - // overrides the style settings. The format of the format string - // is as defined by the ICU library, and is similar to that found - // in Microsoft Excel and NSNumberFormatter. - // The number formatter starts with a default format string defined - // by the style argument with which it was created. - - -CF_EXPORT -CFStringRef CFNumberFormatterCreateStringWithNumber(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFNumberRef number); - -CF_EXPORT -CFStringRef CFNumberFormatterCreateStringWithValue(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFNumberType numberType, const void *valuePtr); - // Create a string representation of the given number or value - // using the current state of the number formatter. - - -typedef CF_OPTIONS(CFOptionFlags, CFNumberFormatterOptionFlags) { - kCFNumberFormatterParseIntegersOnly = 1 /* only parse integers */ -}; - -CF_EXPORT -CFNumberRef CFNumberFormatterCreateNumberFromString(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFStringRef string, CFRange *rangep, CFOptionFlags options); - -CF_EXPORT -Boolean CFNumberFormatterGetValueFromString(CFNumberFormatterRef formatter, CFStringRef string, CFRange *rangep, CFNumberType numberType, void *valuePtr); - // Parse a string representation of a number using the current state - // of the number formatter. The range parameter specifies the range - // of the string in which the parsing should occur in input, and on - // output indicates the extent that was used; this parameter can - // be NULL, in which case the whole string may be used. The - // return value indicates whether some number was computed and - // (if valuePtr is not NULL) stored at the location specified by - // valuePtr. The numberType indicates the type of value pointed - // to by valuePtr. - - -CF_EXPORT -void CFNumberFormatterSetProperty(CFNumberFormatterRef formatter, CFStringRef key, CFTypeRef value); - -CF_EXPORT -CFTypeRef CFNumberFormatterCopyProperty(CFNumberFormatterRef formatter, CFStringRef key); - // Set and get various properties of the number formatter, the set of - // which may be expanded in the future. - -CF_EXPORT const CFStringRef kCFNumberFormatterCurrencyCode; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterDecimalSeparator; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterCurrencyDecimalSeparator; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterAlwaysShowDecimalSeparator; // CFBoolean -CF_EXPORT const CFStringRef kCFNumberFormatterGroupingSeparator; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterUseGroupingSeparator; // CFBoolean -CF_EXPORT const CFStringRef kCFNumberFormatterPercentSymbol; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterZeroSymbol; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterNaNSymbol; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterInfinitySymbol; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterMinusSign; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterPlusSign; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterCurrencySymbol; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterExponentSymbol; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterMinIntegerDigits; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterMaxIntegerDigits; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterMinFractionDigits; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterMaxFractionDigits; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterGroupingSize; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterSecondaryGroupingSize; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterRoundingMode; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterRoundingIncrement; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterFormatWidth; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterPaddingPosition; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterPaddingCharacter; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterDefaultFormat; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterMultiplier; // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterPositivePrefix; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterPositiveSuffix; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterNegativePrefix; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterNegativeSuffix; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterPerMillSymbol; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterInternationalCurrencySymbol; // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterCurrencyGroupingSeparator CF_AVAILABLE(10_5, 2_0); // CFString -CF_EXPORT const CFStringRef kCFNumberFormatterIsLenient CF_AVAILABLE(10_5, 2_0); // CFBoolean -CF_EXPORT const CFStringRef kCFNumberFormatterUseSignificantDigits CF_AVAILABLE(10_5, 2_0); // CFBoolean -CF_EXPORT const CFStringRef kCFNumberFormatterMinSignificantDigits CF_AVAILABLE(10_5, 2_0); // CFNumber -CF_EXPORT const CFStringRef kCFNumberFormatterMaxSignificantDigits CF_AVAILABLE(10_5, 2_0); // CFNumber - -typedef CF_ENUM(CFIndex, CFNumberFormatterRoundingMode) { - kCFNumberFormatterRoundCeiling = 0, - kCFNumberFormatterRoundFloor = 1, - kCFNumberFormatterRoundDown = 2, - kCFNumberFormatterRoundUp = 3, - kCFNumberFormatterRoundHalfEven = 4, - kCFNumberFormatterRoundHalfDown = 5, - kCFNumberFormatterRoundHalfUp = 6 -}; - -typedef CF_ENUM(CFIndex, CFNumberFormatterPadPosition) { - kCFNumberFormatterPadBeforePrefix = 0, - kCFNumberFormatterPadAfterPrefix = 1, - kCFNumberFormatterPadBeforeSuffix = 2, - kCFNumberFormatterPadAfterSuffix = 3 -}; - - -CF_EXPORT -Boolean CFNumberFormatterGetDecimalInfoForCurrencyCode(CFStringRef currencyCode, int32_t *defaultFractionDigits, double *roundingIncrement); - // Returns the number of fraction digits that should be displayed, and - // the rounding increment (or 0.0 if no rounding is done by the currency) - // for the given currency. Returns false if the currency code is unknown - // or the information is not available. - // Not localized because these are properties of the currency. - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFNUMBERFORMATTER__ */ - diff --git a/CFNumberFormatter.h b/CFNumberFormatter.h new file mode 120000 index 0000000..18245db --- /dev/null +++ b/CFNumberFormatter.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFNumberFormatter.h \ No newline at end of file diff --git a/CFPlugIn.h b/CFPlugIn.h deleted file mode 100644 index 96df296..0000000 --- a/CFPlugIn.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFPlugIn.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFPLUGIN__) -#define __COREFOUNDATION_CFPLUGIN__ 1 - -#if !defined(COREFOUNDATION_CFPLUGINCOM_SEPARATE) -#define COREFOUNDATION_CFPLUGINCOM_SEPARATE 1 -#endif - -#include -#include -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -/* ================ Standard Info.plist keys for plugIns ================ */ - -CF_EXPORT const CFStringRef kCFPlugInDynamicRegistrationKey; -CF_EXPORT const CFStringRef kCFPlugInDynamicRegisterFunctionKey; -CF_EXPORT const CFStringRef kCFPlugInUnloadFunctionKey; -CF_EXPORT const CFStringRef kCFPlugInFactoriesKey; -CF_EXPORT const CFStringRef kCFPlugInTypesKey; - -/* ================= Function prototypes for various callbacks ================= */ -/* Function types that plugIn authors can implement for various purposes. */ - -typedef void (*CFPlugInDynamicRegisterFunction)(CFPlugInRef plugIn); -typedef void (*CFPlugInUnloadFunction)(CFPlugInRef plugIn); -typedef void *(*CFPlugInFactoryFunction)(CFAllocatorRef allocator, CFUUIDRef typeUUID); - -/* ================= Creating PlugIns ================= */ - -CF_EXPORT CFTypeID CFPlugInGetTypeID(void); - -CF_EXPORT CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL); - /* Might return an existing instance with the ref-count bumped. */ - -CF_EXPORT CFBundleRef CFPlugInGetBundle(CFPlugInRef plugIn); - -/* ================= Controlling load on demand ================= */ -/* For plugIns. */ -/* PlugIns that do static registration are load on demand by default. */ -/* PlugIns that do dynamic registration are not load on demand by default. */ -/* A dynamic registration function can call CFPlugInSetLoadOnDemand(). */ - -CF_EXPORT void CFPlugInSetLoadOnDemand(CFPlugInRef plugIn, Boolean flag); - -CF_EXPORT Boolean CFPlugInIsLoadOnDemand(CFPlugInRef plugIn); - -/* ================= Finding factories and creating instances ================= */ -/* For plugIn hosts. */ -/* Functions for finding factories to create specific types and actually creating instances of a type. */ - -/* This function finds all the factories from any plugin for the given type. Returns an array that the caller must release. */ -CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInType(CFUUIDRef typeUUID) CF_RETURNS_RETAINED; - - -/* 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. */ -CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInTypeInPlugIn(CFUUIDRef typeUUID, CFPlugInRef plugIn) CF_RETURNS_RETAINED; - -/* This function returns the IUnknown interface for the new instance. */ -CF_EXPORT void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID); - -/* ================= Registering factories and types ================= */ -/* For plugIn writers who must dynamically register things. */ -/* Functions to register factory functions and to associate factories with types. */ - -CF_EXPORT Boolean CFPlugInRegisterFactoryFunction(CFUUIDRef factoryUUID, CFPlugInFactoryFunction func); - -CF_EXPORT Boolean CFPlugInRegisterFactoryFunctionByName(CFUUIDRef factoryUUID, CFPlugInRef plugIn, CFStringRef functionName); - -CF_EXPORT Boolean CFPlugInUnregisterFactory(CFUUIDRef factoryUUID); - -CF_EXPORT Boolean CFPlugInRegisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID); - -CF_EXPORT Boolean CFPlugInUnregisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID); - -/* ================= Registering instances ================= */ -/* 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. */ -/* 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. */ - -CF_EXPORT void CFPlugInAddInstanceForFactory(CFUUIDRef factoryID); - -CF_EXPORT void CFPlugInRemoveInstanceForFactory(CFUUIDRef factoryID); - - -/* Obsolete API */ - -typedef struct __CFPlugInInstance *CFPlugInInstanceRef; - -typedef Boolean (*CFPlugInInstanceGetInterfaceFunction)(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl); -typedef void (*CFPlugInInstanceDeallocateInstanceDataFunction)(void *instanceData); - -CF_EXPORT Boolean CFPlugInInstanceGetInterfaceFunctionTable(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl); - -/* This function returns a retained object on 10.8 or later. */ -CF_EXPORT CFStringRef CFPlugInInstanceGetFactoryName(CFPlugInInstanceRef instance) CF_RETURNS_RETAINED; - -CF_EXPORT void *CFPlugInInstanceGetInstanceData(CFPlugInInstanceRef instance); - -CF_EXPORT CFTypeID CFPlugInInstanceGetTypeID(void); - -CF_EXPORT CFPlugInInstanceRef CFPlugInInstanceCreateWithInstanceDataSize(CFAllocatorRef allocator, CFIndex instanceDataSize, CFPlugInInstanceDeallocateInstanceDataFunction deallocateInstanceFunction, CFStringRef factoryName, CFPlugInInstanceGetInterfaceFunction getInterfaceFunction); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#if !COREFOUNDATION_CFPLUGINCOM_SEPARATE -#include -#endif /* !COREFOUNDATION_CFPLUGINCOM_SEPARATE */ - -#endif /* ! __COREFOUNDATION_CFPLUGIN__ */ - diff --git a/CFPlugIn.h b/CFPlugIn.h new file mode 120000 index 0000000..42eea74 --- /dev/null +++ b/CFPlugIn.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFPlugIn.h \ No newline at end of file diff --git a/CFPlugInCOM.h b/CFPlugInCOM.h deleted file mode 100644 index 9e2859f..0000000 --- a/CFPlugInCOM.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFPlugInCOM.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFPLUGINCOM__) -#define __COREFOUNDATION_CFPLUGINCOM__ 1 - -#include - -CF_EXTERN_C_BEGIN - -/* ================= IUnknown definition (C struct) ================= */ - -/* All interface structs must have an IUnknownStruct at the beginning. */ -/* The _reserved field is part of the Microsoft COM binary standard on Macintosh. */ -/* You can declare new C struct interfaces by defining a new struct that includes "IUNKNOWN_C_GUTS;" before the first field of the struct. */ - -typedef SInt32 HRESULT; -typedef UInt32 ULONG; -typedef void *LPVOID; -typedef CFUUIDBytes REFIID; - -#define SUCCEEDED(Status) ((HRESULT)(Status) >= 0) -#define FAILED(Status) ((HRESULT)(Status)<0) - -/* Macros for more detailed HRESULT analysis */ -#define IS_ERROR(Status) ((unsigned long)(Status) >> 31 == SEVERITY_ERROR) -#define HRESULT_CODE(hr) ((hr) & 0xFFFF) -#define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff) -#define HRESULT_SEVERITY(hr) (((hr) >> 31) & 0x1) -#define SEVERITY_SUCCESS 0 -#define SEVERITY_ERROR 1 - -/* Creating an HRESULT from its component pieces */ -#define MAKE_HRESULT(sev,fac,code) ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) ) - -/* Pre-defined success HRESULTS */ -#define S_OK ((HRESULT)0x00000000L) -#define S_FALSE ((HRESULT)0x00000001L) - -/* Common error HRESULTS */ -#define E_UNEXPECTED ((HRESULT)0x8000FFFFL) -#define E_NOTIMPL ((HRESULT)0x80000001L) -#define E_OUTOFMEMORY ((HRESULT)0x80000002L) -#define E_INVALIDARG ((HRESULT)0x80000003L) -#define E_NOINTERFACE ((HRESULT)0x80000004L) -#define E_POINTER ((HRESULT)0x80000005L) -#define E_HANDLE ((HRESULT)0x80000006L) -#define E_ABORT ((HRESULT)0x80000007L) -#define E_FAIL ((HRESULT)0x80000008L) -#define E_ACCESSDENIED ((HRESULT)0x80000009L) - -/* This macro should be used when defining all interface functions (as it is for the IUnknown functions below). */ -#define STDMETHODCALLTYPE - -/* 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. */ -#define __RPC_FAR - -/* The IUnknown interface */ -#define IUnknownUUID CFUUIDGetConstantUUIDWithBytes(kCFAllocatorSystemDefault, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) - -#define IUNKNOWN_C_GUTS \ - void *_reserved; \ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(void *thisPointer, REFIID iid, LPVOID *ppv); \ - ULONG (STDMETHODCALLTYPE *AddRef)(void *thisPointer); \ - ULONG (STDMETHODCALLTYPE *Release)(void *thisPointer) - -typedef struct IUnknownVTbl { - IUNKNOWN_C_GUTS; -} IUnknownVTbl; - -CF_EXTERN_C_END - - -/* C++ specific stuff */ -#if defined(__cplusplus) -/* ================= IUnknown definition (C++ class) ================= */ - -/* 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) */ - -class IUnknown -#if defined(__MWERKS__) && TARGET_OS_WIN32 - : __comobject -#endif -{ - public: - virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) = 0; - virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0; - virtual ULONG STDMETHODCALLTYPE Release(void) = 0; -}; - -#endif /* __cplusplus */ - -#endif /* ! __COREFOUNDATION_CFPLUGINCOM__ */ - diff --git a/CFPlugInCOM.h b/CFPlugInCOM.h new file mode 120000 index 0000000..36e038a --- /dev/null +++ b/CFPlugInCOM.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFPlugInCOM.h \ No newline at end of file diff --git a/CFPlugIn_Factory.h b/CFPlugIn_Factory.h deleted file mode 100644 index 84f84be..0000000 --- a/CFPlugIn_Factory.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFPlugIn_Factory.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFPLUGIN_FACTORY__) -#define __COREFOUNDATION_CFPLUGIN_FACTORY__ 1 - -#include "CFBundle_Internal.h" - -CF_EXTERN_C_BEGIN - -typedef struct __CFPFactory *_CFPFactoryRef; - -extern _CFPFactoryRef _CFPFactoryCreate(CFAllocatorRef allocator, CFUUIDRef factoryID, CFPlugInFactoryFunction func); -extern _CFPFactoryRef _CFPFactoryCreateByName(CFAllocatorRef allocator, CFUUIDRef factoryID, CFPlugInRef plugIn, CFStringRef funcName); - -extern _CFPFactoryRef _CFPFactoryFind(CFUUIDRef factoryID, Boolean enabled); - -extern CFUUIDRef _CFPFactoryCopyFactoryID(_CFPFactoryRef factory); -extern CFPlugInRef _CFPFactoryCopyPlugIn(_CFPFactoryRef factory); - -extern void *_CFPFactoryCreateInstance(CFAllocatorRef allocator, _CFPFactoryRef factory, CFUUIDRef typeID); -extern void _CFPFactoryDisable(_CFPFactoryRef factory); - -extern void _CFPFactoryFlushFunctionCache(_CFPFactoryRef factory); - -extern void _CFPFactoryAddType(_CFPFactoryRef factory, CFUUIDRef typeID); -extern void _CFPFactoryRemoveType(_CFPFactoryRef factory, CFUUIDRef typeID); - -extern Boolean _CFPFactorySupportsType(_CFPFactoryRef factory, CFUUIDRef typeID); -extern CFArrayRef _CFPFactoryFindCopyForType(CFUUIDRef typeID); - -/* 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. */ -extern void _CFPFactoryAddInstance(_CFPFactoryRef factory); -extern void _CFPFactoryRemoveInstance(_CFPFactoryRef factory); - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFPLUGIN_FACTORY__ */ - diff --git a/CFPlugIn_Factory.h b/CFPlugIn_Factory.h new file mode 120000 index 0000000..97d5cd2 --- /dev/null +++ b/CFPlugIn_Factory.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFPlugIn_Factory.h \ No newline at end of file diff --git a/CFPreferences.h b/CFPreferences.h deleted file mode 100644 index da7a686..0000000 --- a/CFPreferences.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFPreferences.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFPREFERENCES__) -#define __COREFOUNDATION_CFPREFERENCES__ 1 - -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -CF_EXPORT -const CFStringRef kCFPreferencesAnyApplication; -CF_EXPORT -const CFStringRef kCFPreferencesCurrentApplication; -CF_EXPORT -const CFStringRef kCFPreferencesAnyHost; -CF_EXPORT -const CFStringRef kCFPreferencesCurrentHost; -CF_EXPORT -const CFStringRef kCFPreferencesAnyUser; -CF_EXPORT -const CFStringRef kCFPreferencesCurrentUser; - -/* NOTE: All CFPropertyListRef values returned from - CFPreferences API should be assumed to be immutable. -*/ - -/* The "App" functions search the various sources of defaults that - apply to the given application, and should never be called with - kCFPreferencesAnyApplication - only kCFPreferencesCurrentApplication - or an application's ID (its bundle identifier). -*/ - -/* Searches the various sources of application defaults to find the -value for the given key. key must not be NULL. If a value is found, -it returns it; otherwise returns NULL. Caller must release the -returned value */ -CF_EXPORT -CFPropertyListRef CFPreferencesCopyAppValue(CFStringRef key, CFStringRef applicationID); - -/* Convenience to interpret a preferences value as a boolean directly. -Returns false if the key doesn't exist, or has an improper format; under -those conditions, keyExistsAndHasValidFormat (if non-NULL) is set to false */ -CF_EXPORT -Boolean CFPreferencesGetAppBooleanValue(CFStringRef key, CFStringRef applicationID, Boolean *keyExistsAndHasValidFormat); - -/* Convenience to interpret a preferences value as an integer directly. -Returns 0 if the key doesn't exist, or has an improper format; under -those conditions, keyExistsAndHasValidFormat (if non-NULL) is set to false */ -CF_EXPORT -CFIndex CFPreferencesGetAppIntegerValue(CFStringRef key, CFStringRef applicationID, Boolean *keyExistsAndHasValidFormat); - -/* Sets the given value for the given key in the "normal" place for -application preferences. key must not be NULL. If value is NULL, -key is removed instead. */ -CF_EXPORT -void CFPreferencesSetAppValue(CFStringRef key, CFPropertyListRef value, CFStringRef applicationID); - -/* Adds the preferences for the given suite to the app preferences for - the specified application. To write to the suite domain, use - CFPreferencesSetValue(), below, using the suiteName in place - of the appName */ -CF_EXPORT -void CFPreferencesAddSuitePreferencesToApp(CFStringRef applicationID, CFStringRef suiteID); - -CF_EXPORT -void CFPreferencesRemoveSuitePreferencesFromApp(CFStringRef applicationID, CFStringRef suiteID); - -/* Writes all changes in all sources of application defaults. -Returns success or failure. */ -CF_EXPORT -Boolean CFPreferencesAppSynchronize(CFStringRef applicationID); - -/* The primitive get mechanism; all arguments must be non-NULL -(use the constants above for common values). Only the exact -location specified by app-user-host is searched. The returned -CFType must be released by the caller when it is finished with it. */ -CF_EXPORT -CFPropertyListRef CFPreferencesCopyValue(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); - -/* Convenience to fetch multiple keys at once. Keys in -keysToFetch that are not present in the returned dictionary -are not present in the domain. If keysToFetch is NULL, all -keys are fetched. */ -CF_EXPORT -CFDictionaryRef CFPreferencesCopyMultiple(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); - -/* The primitive set function; all arguments except value must be -non-NULL. If value is NULL, the given key is removed */ -CF_EXPORT -void CFPreferencesSetValue(CFStringRef key, CFPropertyListRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); - -/* Convenience to set multiple values at once. Behavior is undefined -if a key is in both keysToSet and keysToRemove */ -CF_EXPORT -void CFPreferencesSetMultiple(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); - -CF_EXPORT -Boolean CFPreferencesSynchronize(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); - -/* Constructs and returns the list of the name of all applications -which have preferences in the scope of the given user and host. -The returned value must be released by the caller; neither argument -may be NULL. */ -CF_EXPORT -CFArrayRef CFPreferencesCopyApplicationList(CFStringRef userName, CFStringRef hostName) CF_DEPRECATED(10_0, 10_9, 2_0, 7_0); - -/* Constructs and returns the list of all keys set in the given -location. The returned value must be released by the caller; -all arguments must be non-NULL */ -CF_EXPORT -CFArrayRef CFPreferencesCopyKeyList(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); - - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFPREFERENCES__ */ - diff --git a/CFPreferences.h b/CFPreferences.h new file mode 120000 index 0000000..61def84 --- /dev/null +++ b/CFPreferences.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFPreferences.h \ No newline at end of file diff --git a/CFPriv.h b/CFPriv.h deleted file mode 100644 index 72131bc..0000000 --- a/CFPriv.h +++ /dev/null @@ -1,660 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFPriv.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -/* - APPLE SPI: NOT TO BE USED OUTSIDE APPLE! -*/ - -#if !defined(__COREFOUNDATION_CFPRIV__) -#define __COREFOUNDATION_CFPRIV__ 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -#include -#include -#endif - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || TARGET_OS_WIN32 -#include -#include -#include -#endif - -CF_EXTERN_C_BEGIN - -CF_EXPORT intptr_t _CFDoOperation(intptr_t code, intptr_t subcode1, intptr_t subcode2); - -CF_EXPORT void _CFRuntimeSetCFMPresent(void *a); - -CF_EXPORT const char *_CFProcessPath(void); -CF_EXPORT const char **_CFGetProcessPath(void); -CF_EXPORT const char **_CFGetProgname(void); - - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) -CF_EXPORT void _CFRunLoopSetCurrent(CFRunLoopRef rl); -#endif - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -CF_EXPORT CFRunLoopRef CFRunLoopGetMain(void); -CF_EXPORT SInt32 CFRunLoopRunSpecific(CFRunLoopRef rl, CFStringRef modeName, CFTimeInterval seconds, Boolean returnAfterSourceHandled); - - -CF_EXPORT void _CFRunLoopStopMode(CFRunLoopRef rl, CFStringRef modeName); - -CF_EXPORT CFIndex CFMachPortGetQueuedMessageCount(CFMachPortRef mp); - -CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url); -#endif -CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url); -CF_EXPORT CFURLRef _CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc, CFPropertyListRef pListRepresentation); - -CF_EXPORT void CFPreferencesFlushCaches(void); - - - -#if TARGET_OS_WIN32 -CF_EXPORT Boolean _CFURLGetWideFileSystemRepresentation(CFURLRef url, Boolean resolveAgainstBase, wchar_t *buffer, CFIndex bufferLength); -#endif - -#if !__LP64__ -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -struct FSSpec; -CF_EXPORT -Boolean _CFGetFSSpecFromURL(CFAllocatorRef alloc, CFURLRef url, struct FSSpec *spec); - -CF_EXPORT -CFURLRef _CFCreateURLFromFSSpec(CFAllocatorRef alloc, const struct FSSpec *voidspec, Boolean isDirectory); -#endif -#endif - -typedef CF_ENUM(CFIndex, CFURLComponentDecomposition) { - kCFURLComponentDecompositionNonHierarchical, - kCFURLComponentDecompositionRFC1808, /* use this for RFC 1738 decompositions as well */ - kCFURLComponentDecompositionRFC2396 -}; - -typedef struct { - CFStringRef scheme; - CFStringRef schemeSpecific; -} CFURLComponentsNonHierarchical; - -typedef struct { - CFStringRef scheme; - CFStringRef user; - CFStringRef password; - CFStringRef host; - CFIndex port; /* kCFNotFound means ignore/omit */ - CFArrayRef pathComponents; - CFStringRef parameterString; - CFStringRef query; - CFStringRef fragment; - CFURLRef baseURL; -} CFURLComponentsRFC1808; - -typedef struct { - CFStringRef scheme; - - /* if the registered name form of the net location is used, userinfo is NULL, port is kCFNotFound, and host is the entire registered name. */ - CFStringRef userinfo; - CFStringRef host; - CFIndex port; - - CFArrayRef pathComponents; - CFStringRef query; - CFStringRef fragment; - CFURLRef baseURL; -} CFURLComponentsRFC2396; - -/* Fills components and returns TRUE if the URL can be decomposed according to decompositionType; FALSE (leaving components unchanged) otherwise. components should be a pointer to the CFURLComponents struct defined above that matches decompositionStyle */ -CF_EXPORT -Boolean _CFURLCopyComponents(CFURLRef url, CFURLComponentDecomposition decompositionType, void *components); - -/* Creates and returns the URL described by components; components should point to the CFURLComponents struct defined above that matches decompositionType. */ -CF_EXPORT -CFURLRef _CFURLCreateFromComponents(CFAllocatorRef alloc, CFURLComponentDecomposition decompositionType, const void *components); -#define CFURLCopyComponents _CFURLCopyComponents -#define CFURLCreateFromComponents _CFURLCreateFromComponents - - - -CF_EXPORT Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *buffer, CFIndex maxBufLen); - -/* If this is publicized, we might need to create a GetBytesPtr type function as well. */ -CF_EXPORT CFStringRef _CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat, CFAllocatorRef contentsDeallocator); - -/* These return NULL on MacOS 8 */ -// This one leaks the returned string in order to be thread-safe. -// CF cannot help you in this matter if you continue to use this SPI. -CF_EXPORT -CFStringRef CFGetUserName(void); - -CF_EXPORT -CFStringRef CFCopyUserName(void); - -CF_EXPORT -CFURLRef CFCopyHomeDirectoryURLForUser(CFStringRef uName); /* Pass NULL for the current user's home directory */ - - -/* - CFCopySearchPathForDirectoriesInDomains returns the various - standard system directories where apps, resources, etc get - installed. Because queries can return multiple directories, - you get back a CFArray (which you should free when done) of - CFURLs. The directories are returned in search path order; - that is, the first place to look is returned first. This API - may return directories that do not exist yet. If NSUserDomain - is included in a query, then the results will contain "~" to - refer to the user's directory. Specify expandTilde to expand - this to the current user's home. Some calls might return no - directories! - ??? On MacOS 8 this function currently returns an empty array. -*/ -typedef CF_ENUM(CFIndex, CFSearchPathDirectory) { - kCFApplicationDirectory = 1, /* supported applications (Applications) */ - kCFDemoApplicationDirectory, /* unsupported applications, demonstration versions (Demos) */ - kCFDeveloperApplicationDirectory, /* developer applications (Developer/Applications) */ - kCFAdminApplicationDirectory, /* system and network administration applications (Administration) */ - kCFLibraryDirectory, /* various user-visible documentation, support, and configuration files, resources (Library) */ - kCFDeveloperDirectory, /* developer resources (Developer) */ - kCFUserDirectory, /* user home directories (Users) */ - kCFDocumentationDirectory, /* documentation (Documentation) */ - kCFDocumentDirectory, /* documents (Library/Documents) */ - - kCFCoreServiceDirectory = 10, // location of CoreServices directory (System/Library/CoreServices) - kCFAutosavedInformationDirectory = 11, // location of autosaved documents (Documents/Autosaved) - kCFDesktopDirectory = 12, // location of user's desktop - kCFCachesDirectory = 13, // location of discardable cache files (Library/Caches) - kCFApplicationSupportDirectory = 14, // location of application support files (plug-ins, etc) (Library/Application Support) - kCFDownloadsDirectory = 15, // location of the user's "Downloads" directory - kCFInputMethodsDirectory = 16, // input methods (Library/Input Methods) - kCFMoviesDirectory = 17, // location of user's Movies directory (~/Movies) - kCFMusicDirectory = 18, // location of user's Music directory (~/Music) - kCFPicturesDirectory = 19, // location of user's Pictures directory (~/Pictures) - kCFPrinterDescriptionDirectory = 20, // location of system's PPDs directory (Library/Printers/PPDs) - kCFSharedPublicDirectory = 21, // location of user's Public sharing directory (~/Public) - kCFPreferencePanesDirectory = 22, // location of the PreferencePanes directory for use with System Preferences (Library/PreferencePanes) - - kCFAllApplicationsDirectory = 100, /* all directories where applications can occur (ie Applications, Demos, Administration, Developer/Applications) */ - kCFAllLibrariesDirectory = 101 /* all directories where resources can occur (Library, Developer) */ -}; - -typedef CF_OPTIONS(CFOptionFlags, CFSearchPathDomainMask) { - kCFUserDomainMask = 1, /* user's home directory --- place to install user's personal items (~) */ - kCFLocalDomainMask = 2, /* local to the current machine --- place to install items available to everyone on this machine (/Local) */ - kCFNetworkDomainMask = 4, /* publically available location in the local area network --- place to install items available on the network (/Network) */ - kCFSystemDomainMask = 8, /* provided by Apple, unmodifiable (/System) */ - kCFAllDomainsMask = 0x0ffff /* all domains: all of the above and more, future items */ -}; - -CF_EXPORT -CFArrayRef CFCopySearchPathForDirectoriesInDomains(CFSearchPathDirectory directory, CFSearchPathDomainMask domainMask, Boolean expandTilde); - - -/* Obsolete keys */ -CF_EXPORT const CFStringRef kCFFileURLExists; -CF_EXPORT const CFStringRef kCFFileURLPOSIXMode; -CF_EXPORT const CFStringRef kCFFileURLSize; -CF_EXPORT const CFStringRef kCFFileURLDirectoryContents; -CF_EXPORT const CFStringRef kCFFileURLLastModificationTime; -CF_EXPORT const CFStringRef kCFHTTPURLStatusCode; -CF_EXPORT const CFStringRef kCFHTTPURLStatusLine; - - -/* System Version file access */ -CF_EXPORT CFStringRef CFCopySystemVersionString(void); // Human-readable string containing both marketing and build version -CF_EXPORT CFDictionaryRef _CFCopySystemVersionDictionary(void); -CF_EXPORT CFDictionaryRef _CFCopyServerVersionDictionary(void); -CF_EXPORT const CFStringRef _kCFSystemVersionProductNameKey; -CF_EXPORT const CFStringRef _kCFSystemVersionProductCopyrightKey; -CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionKey; -CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionExtraKey; -CF_EXPORT const CFStringRef _kCFSystemVersionProductUserVisibleVersionKey; // For loginwindow; see 2987512 -CF_EXPORT const CFStringRef _kCFSystemVersionBuildVersionKey; -CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionStringKey; // Localized string for the string "Version" -CF_EXPORT const CFStringRef _kCFSystemVersionBuildStringKey; // Localized string for the string "Build" - - -CF_EXPORT void CFMergeSortArray(void *list, CFIndex count, CFIndex elementSize, CFComparatorFunction comparator, void *context); -CF_EXPORT void CFQSortArray(void *list, CFIndex count, CFIndex elementSize, CFComparatorFunction comparator, void *context); - -/* _CFExecutableLinkedOnOrAfter(releaseVersionName) will return YES if the current executable seems to be linked on or after the specified release. Example: If you specify CFSystemVersionPuma (10.1), you will get back true for executables linked on Puma or Jaguar(10.2), but false for those linked on Cheetah (10.0) or any of its software updates (10.0.x). You will also get back false for any app whose version info could not be figured out. - This function caches its results, so no need to cache at call sites. - - Note that for non-MACH this function always returns true. -*/ -typedef CF_ENUM(CFIndex, CFSystemVersion) { - CFSystemVersionCheetah = 0, /* 10.0 */ - CFSystemVersionPuma = 1, /* 10.1 */ - CFSystemVersionJaguar = 2, /* 10.2 */ - CFSystemVersionPanther = 3, /* 10.3 */ - CFSystemVersionTiger = 4, /* 10.4 */ - CFSystemVersionLeopard = 5, /* 10.5 */ - CFSystemVersionSnowLeopard = 6, /* 10.6 */ - CFSystemVersionLion = 7, /* 10.7 */ - CFSystemVersionMountainLion = 8, /* 10.8 */ - CFSystemVersionMax, /* This should bump up when new entries are added */ - -}; - -CF_EXPORT Boolean _CFExecutableLinkedOnOrAfter(CFSystemVersion version); - - -typedef CF_ENUM(CFIndex, CFStringCharacterClusterType) { - kCFStringGraphemeCluster = 1, /* Unicode Grapheme Cluster */ - kCFStringComposedCharacterCluster = 2, /* Compose all non-base (including spacing marks) */ - kCFStringCursorMovementCluster = 3, /* Cluster suitable for cursor movements */ - kCFStringBackwardDeletionCluster = 4 /* Cluster suitable for backward deletion */ -}; - -CF_EXPORT CFRange CFStringGetRangeOfCharacterClusterAtIndex(CFStringRef string, CFIndex charIndex, CFStringCharacterClusterType type); - -// Compatibility kCFCompare flags. Use the new public kCFCompareDiacriticInsensitive -enum { - kCFCompareDiacriticsInsensitive = 128 /* Use kCFCompareDiacriticInsensitive */ -}; - -/* kCFCompare flags planned to be publicized (Aki 10/20/2008 Does not work with kCFCompareForceOrdering/CFStringFold). see ) - */ -enum { - kCFCompareIgnoreNonAlphanumeric = (1UL << 16), // Ignores characters NOT in kCFCharacterSetAlphaNumeric -}; - - -/* CFStringEncoding SPI */ -/* When set, CF encoding conversion engine keeps ASCII compatibility. (i.e. ASCII backslash <-> Unicode backslash in MacJapanese */ -CF_EXPORT void _CFStringEncodingSetForceASCIICompatibility(Boolean flag); - -extern void __CFSetCharToUniCharFunc(Boolean (*func)(UInt32 flags, UInt8 ch, UniChar *unicodeChar)); -extern UniChar __CFCharToUniCharTable[256]; - - -#if defined(CF_INLINE) -CF_INLINE const UniChar *CFStringGetCharactersPtrFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange) { - if ((desiredRange.location < 0) || ((desiredRange.location + desiredRange.length) > buf->rangeToBuffer.length)) return NULL; - - if (buf->directUniCharBuffer) { - return buf->directUniCharBuffer + buf->rangeToBuffer.location + desiredRange.location; - } else { - if (desiredRange.length > __kCFStringInlineBufferLength) return NULL; - - if (((desiredRange.location + desiredRange.length) > buf->bufferedRangeEnd) || (desiredRange.location < buf->bufferedRangeStart)) { - buf->bufferedRangeStart = desiredRange.location; - buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength; - if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length; - CFIndex location = buf->rangeToBuffer.location + buf->bufferedRangeStart; - CFIndex length = buf->bufferedRangeEnd - buf->bufferedRangeStart; - if (buf->directCStringBuffer) { - UniChar *bufPtr = buf->buffer; - while (length--) *bufPtr++ = (UniChar)buf->directCStringBuffer[location++]; - } else { - CFStringGetCharacters(buf->theString, CFRangeMake(location, length), buf->buffer); - } - } - - return buf->buffer + (desiredRange.location - buf->bufferedRangeStart); - } -} - -CF_INLINE void CFStringGetCharactersFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange, UniChar *outBuf) { - if (buf->directUniCharBuffer) { - memmove(outBuf, buf->directUniCharBuffer + buf->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar)); - } else { - if ((desiredRange.location >= buf->bufferedRangeStart) && (desiredRange.location < buf->bufferedRangeEnd)) { - CFIndex bufLen = desiredRange.length; - - if (bufLen > (buf->bufferedRangeEnd - desiredRange.location)) bufLen = (buf->bufferedRangeEnd - desiredRange.location); - - memmove(outBuf, buf->buffer + (desiredRange.location - buf->bufferedRangeStart), bufLen * sizeof(UniChar)); - outBuf += bufLen; desiredRange.location += bufLen; desiredRange.length -= bufLen; - } else { - CFIndex desiredRangeMax = (desiredRange.location + desiredRange.length); - - if ((desiredRangeMax > buf->bufferedRangeStart) && (desiredRangeMax < buf->bufferedRangeEnd)) { - desiredRange.length = (buf->bufferedRangeStart - desiredRange.location); - memmove(outBuf + desiredRange.length, buf->buffer, (desiredRangeMax - buf->bufferedRangeStart) * sizeof(UniChar)); - } - } - - if (desiredRange.length > 0) { - CFIndex location = buf->rangeToBuffer.location + desiredRange.location; - CFIndex length = desiredRange.length; - if (buf->directCStringBuffer) { - UniChar *bufPtr = outBuf; - while (length--) *bufPtr++ = (UniChar)buf->directCStringBuffer[location++]; - } else { - CFStringGetCharacters(buf->theString, CFRangeMake(location, length), outBuf); - } - } - } -} - -#else -#define CFStringGetCharactersPtrFromInlineBuffer(buf, desiredRange) ((buf)->directUniCharBuffer ? (buf)->directUniCharBuffer + (buf)->rangeToBuffer.location + desiredRange.location : NULL) - -#define CFStringGetCharactersFromInlineBuffer(buf, desiredRange, outBuf) \ - if (buf->directUniCharBuffer) memmove(outBuf, (buf)->directUniCharBuffer + (buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar)); \ - else CFStringGetCharacters((buf)->theString, CFRangeMake((buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf); - -#endif /* CF_INLINE */ - - -#if defined(CF_INLINE) - -#ifndef __kCFStringAppendBufferLength - #define __kCFStringAppendBufferLength 1024 -#endif -typedef struct { - UniChar buffer[__kCFStringAppendBufferLength]; - CFIndex bufferIndex; - CFMutableStringRef theString; -} CFStringAppendBuffer; - - -// Initializes CFStringAppendBuffer with new mutable string. -CF_INLINE void CFStringInitAppendBuffer(CFAllocatorRef alloc, CFStringAppendBuffer *buf) -{ - buf->bufferIndex = 0; - buf->theString = CFStringCreateMutable(alloc, 0); -} - -// Appends the characters of a string to the CFStringAppendBuffer. -CF_INLINE void CFStringAppendStringToAppendBuffer(CFStringAppendBuffer *buf, CFStringRef appendedString) -{ - CFIndex numChars = CFStringGetLength(appendedString); - if ( numChars > __kCFStringAppendBufferLength ) { - if ( buf->bufferIndex ) { - CFStringAppendCharacters(buf->theString, buf->buffer, buf->bufferIndex); - buf->bufferIndex = 0; - } - CFStringAppend(buf->theString, appendedString); - } - else { - if ( (buf->bufferIndex + numChars) > __kCFStringAppendBufferLength ) { - CFStringAppendCharacters(buf->theString, buf->buffer, buf->bufferIndex); - buf->bufferIndex = 0; - } - CFStringGetCharacters(appendedString, CFRangeMake(0, numChars), &buf->buffer[buf->bufferIndex]); - buf->bufferIndex += numChars; - } -} - -// Appends a buffer of Unicode characters to the CFStringAppendBuffer. -CF_INLINE void CFStringAppendCharactersToAppendBuffer(CFStringAppendBuffer *buf, const UniChar *chars, CFIndex numChars) -{ - if ( numChars > __kCFStringAppendBufferLength ) { - if ( buf->bufferIndex ) { - CFStringAppendCharacters(buf->theString, buf->buffer, buf->bufferIndex); - buf->bufferIndex = 0; - } - CFStringAppendCharacters(buf->theString, chars, numChars); - } - else { - if ( (buf->bufferIndex + numChars) > __kCFStringAppendBufferLength ) { - CFStringAppendCharacters(buf->theString, buf->buffer, buf->bufferIndex); - buf->bufferIndex = 0; - } - memcpy(&buf->buffer[buf->bufferIndex], chars, numChars * sizeof(UniChar)); - buf->bufferIndex += numChars; - } -} - -// Returns a mutable string from the CFStringAppendBuffer. -CF_INLINE CFMutableStringRef CFStringCreateMutableWithAppendBuffer(CFStringAppendBuffer *buf) -{ - if ( buf->bufferIndex ) { - CFStringAppendCharacters(buf->theString, buf->buffer, buf->bufferIndex); - buf->bufferIndex = 0; - } - CFMutableStringRef result = buf->theString; - buf->theString = NULL; - return ( result ); -} - -#endif /* CF_INLINE */ - -/* - CFCharacterSetInlineBuffer related declarations - */ -/*! -@typedef CFCharacterSetInlineBuffer - @field cset The character set this inline buffer is initialized with. - The object is not retained by the structure. - @field flags The field is a bit mask that carries various settings. - @field rangeStart The beginning of the character range that contains all members. - It is guaranteed that there is no member below this value. - @field rangeLimit The end of the character range that contains all members. - It is guaranteed that there is no member above and equal to this value. - @field bitmap The bitmap data representing the membership of the Basic Multilingual Plane characters. - If NULL, all BMP characters inside the range are members of the character set. - */ -typedef struct { - CFCharacterSetRef cset; - uint32_t flags; - uint32_t rangeStart; - uint32_t rangeLimit; - const uint8_t *bitmap; -} CFCharacterSetInlineBuffer; - -// Bits for flags field -enum { - kCFCharacterSetIsCompactBitmap = (1UL << 0), - kCFCharacterSetNoBitmapAvailable = (1UL << 1), - kCFCharacterSetIsInverted = (1UL << 2) -}; - -/*! -@function CFCharacterSetInitInlineBuffer - Initializes buffer with cset. - @param cset The character set used to initialized the buffer. - If this parameter is not a valid CFCharacterSet, the behavior is undefined. - @param buffer The reference to the inline buffer to be initialized. - */ -CF_EXPORT -void CFCharacterSetInitInlineBuffer(CFCharacterSetRef cset, CFCharacterSetInlineBuffer *buffer); - -/*! -@function CFCharacterSetInlineBufferIsLongCharacterMember - Reports whether or not the UTF-32 character is in the character set. - @param buffer The reference to the inline buffer to be searched. - @param character The UTF-32 character for which to test against the - character set. - @result true, if the value is in the character set, otherwise false. - */ -#if defined(CF_INLINE) -CF_INLINE bool CFCharacterSetInlineBufferIsLongCharacterMember(const CFCharacterSetInlineBuffer *buffer, UTF32Char character) { - bool isInverted = ((0 == (buffer->flags & kCFCharacterSetIsInverted)) ? false : true); - - if ((character >= buffer->rangeStart) && (character < buffer->rangeLimit)) { - if ((character > 0xFFFF) || (0 != (buffer->flags & kCFCharacterSetNoBitmapAvailable))) return (CFCharacterSetIsLongCharacterMember(buffer->cset, character) != 0); - if (NULL == buffer->bitmap) { - if (0 == (buffer->flags & kCFCharacterSetIsCompactBitmap)) isInverted = !isInverted; - } else if (0 == (buffer->flags & kCFCharacterSetIsCompactBitmap)) { - if (buffer->bitmap[character >> 3] & (1UL << (character & 7))) isInverted = !isInverted; - } else { - uint8_t value = buffer->bitmap[character >> 8]; - - if (value == 0xFF) { - isInverted = !isInverted; - } else if (value > 0) { - const uint8_t *segment = buffer->bitmap + (256 + (32 * (value - 1))); - character &= 0xFF; - if (segment[character >> 3] & (1UL << (character % 8))) isInverted = !isInverted; - } - } - } - return isInverted; -} -#else /* CF_INLINE */ -#define CFCharacterSetInlineBufferIsLongCharacterMember(buffer, character) (CFCharacterSetIsLongCharacterMember(buffer->cset, character)) -#endif /* CF_INLINE */ - - -#if TARGET_OS_WIN32 -CF_EXPORT CFMutableStringRef _CFCreateApplicationRepositoryPath(CFAllocatorRef alloc, int nFolder); -#endif - -CF_EXPORT CFTypeRef _CFTryRetain(CFTypeRef cf); -CF_EXPORT Boolean _CFIsDeallocating(CFTypeRef cf); - -/* - CFLocaleGetLanguageRegionEncodingForLocaleIdentifier gets the appropriate language and region codes, - and the default legacy script code and encoding, for the specified locale (or language) string. - Returns false if CFLocale has no information about the given locale; otherwise may set - *langCode and/or *regCode to -1 if there is no appropriate legacy value for the locale. - This is a replacement for the CFBundle SPI CFBundleGetLocalizationInfoForLocalization (which was intended to be temporary and transitional); - this function is more up-to-date in its handling of locale strings, and is in CFLocale where this functionality should belong. Compared - to CFBundleGetLocalizationInfoForLocalization, this function does not spcially interpret a NULL localeIdentifier to mean use the single most - preferred localization in the current context (this function returns NO for a NULL localeIdentifier); and in this function - langCode, regCode, and scriptCode are all SInt16* (not SInt32* like the equivalent parameters in CFBundleGetLocalizationInfoForLocalization). -*/ -CF_EXPORT -Boolean CFLocaleGetLanguageRegionEncodingForLocaleIdentifier(CFStringRef localeIdentifier, LangCode *langCode, RegionCode *regCode, ScriptCode *scriptCode, CFStringEncoding *stringEncoding); - -#if TARGET_OS_WIN32 -CF_EXPORT CFMutableStringRef _CFCreateApplicationRepositoryPath(CFAllocatorRef alloc, int nFolder); -#endif - -#if TARGET_OS_WIN32 -#include - -#define CF_MESSAGE_PORT_CLONE_MESSAGE_ID -1209 -CF_EXPORT CFMessagePortRef CFMessagePortCreateUber(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo, Boolean isRemote); -CF_EXPORT void CFMessagePortSetCloneCallout(CFMessagePortRef ms, CFMessagePortCallBack cloneCallout); -#endif - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -#include - -CF_EXPORT CFMessagePortRef CFMessagePortCreatePerProcessLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo); -CF_EXPORT CFMessagePortRef CFMessagePortCreatePerProcessRemote(CFAllocatorRef allocator, CFStringRef name, CFIndex pid); - - -typedef CFDataRef (*CFMessagePortCallBackEx)(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info, void *trailer, uintptr_t); - -CF_EXPORT CFMessagePortRef _CFMessagePortCreateLocalEx(CFAllocatorRef allocator, CFStringRef name, Boolean perPID, uintptr_t unused, CFMessagePortCallBackEx callout2, CFMessagePortContext *context, Boolean *shouldFreeInfo); - -#endif - -#if TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX -#include -#else -// Avoid including the pthread header -#ifndef HAVE_STRUCT_TIMESPEC -#define HAVE_STRUCT_TIMESPEC 1 -struct timespec { long tv_sec; long tv_nsec; }; -#endif -#endif - -CF_INLINE CFAbsoluteTime _CFAbsoluteTimeFromFileTimeSpec(struct timespec ts) { - return (CFAbsoluteTime)((CFTimeInterval)ts.tv_sec - kCFAbsoluteTimeIntervalSince1970) + (1.0e-9 * (CFTimeInterval)ts.tv_nsec); -} - -CF_INLINE struct timespec _CFFileTimeSpecFromAbsoluteTime(CFAbsoluteTime at) { - struct timespec ts; - double sec = 0.0; - double frac = modf(at, &sec); - if (frac < 0.0) { - frac += 1.0; - sec -= 1.0; - } -#if TARGET_OS_WIN32 - ts.tv_sec = (long)(sec + kCFAbsoluteTimeIntervalSince1970); -#else - ts.tv_sec = (time_t)(sec + kCFAbsoluteTimeIntervalSince1970); -#endif - ts.tv_nsec = (long)(1000000000UL * frac + 0.5); - return ts; -} - -// The 'filtered' function below is preferred to this older one -CF_EXPORT bool _CFPropertyListCreateSingleValue(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFStringRef keyPath, CFPropertyListRef *value, CFErrorRef *error); - -// Returns a subset of the property list, only including the keyPaths in the CFSet. If the top level object is not a dictionary, you will get back an empty dictionary as the result. -CF_EXPORT bool _CFPropertyListCreateFiltered(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFSetRef keyPaths, CFPropertyListRef *value, CFErrorRef *error) CF_AVAILABLE(10_8, 6_0); - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || TARGET_OS_WIN32 - -// Returns a subset of a bundle's Info.plist. The keyPaths follow the same rules as above CFPropertyList function. This function takes platform and product keys into account. -typedef CF_OPTIONS(CFOptionFlags, _CFBundleFilteredPlistOptions) { - _CFBundleFilteredPlistMemoryMapped = 1 -} CF_ENUM_AVAILABLE(10_8, 6_0); - -CF_EXPORT CFPropertyListRef _CFBundleCreateFilteredInfoPlist(CFBundleRef bundle, CFSetRef keyPaths, _CFBundleFilteredPlistOptions options) CF_AVAILABLE(10_8, 6_0); -CF_EXPORT CFPropertyListRef _CFBundleCreateFilteredLocalizedInfoPlist(CFBundleRef bundle, CFSetRef keyPaths, CFStringRef localizationName, _CFBundleFilteredPlistOptions options) CF_AVAILABLE(10_8, 6_0); -#endif - -#if TARGET_OS_WIN32 -#include - -CF_EXPORT CFStringRef _CFGetWindowsAppleAppDataDirectory(void); -CF_EXPORT CFArrayRef _CFGetWindowsBinaryDirectories(void); -CF_EXPORT CFStringRef _CFGetWindowsAppleSystemLibraryDirectory(void); - -// If your Windows application does not use a CFRunLoop on the main thread (perhaps because it is reserved for handling UI events via Windows API), then call this function to make distributed notifications arrive using a different run loop. -CF_EXPORT void _CFNotificationCenterSetRunLoop(CFNotificationCenterRef nc, CFRunLoopRef rl); - -CF_EXPORT uint32_t /*DWORD*/ _CFRunLoopGetWindowsMessageQueueMask(CFRunLoopRef rl, CFStringRef modeName); -CF_EXPORT void _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopRef rl, uint32_t /*DWORD*/ mask, CFStringRef modeName); - -CF_EXPORT uint32_t /*DWORD*/ _CFRunLoopGetWindowsThreadID(CFRunLoopRef rl); - -typedef void (*CFWindowsMessageQueueHandler)(void); - -// Run Loop parameter must be the current thread's run loop for the next two functions; you cannot use another thread's run loop -CF_EXPORT CFWindowsMessageQueueHandler _CFRunLoopGetWindowsMessageQueueHandler(CFRunLoopRef rl, CFStringRef modeName); -CF_EXPORT void _CFRunLoopSetWindowsMessageQueueHandler(CFRunLoopRef rl, CFStringRef modeName, CFWindowsMessageQueueHandler func); - -#endif - - -CF_EXPORT CFArrayRef CFDateFormatterCreateDateFormatsFromTemplates(CFAllocatorRef allocator, CFArrayRef tmplates, CFOptionFlags options, CFLocaleRef locale); - -#if (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -// Available for internal use on embedded -CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void); -#endif - -CF_EXPORT const CFStringRef kCFNumberFormatterUsesCharacterDirection CF_AVAILABLE(10_9, 6_0); // CFBoolean -CF_EXPORT const CFStringRef kCFDateFormatterUsesCharacterDirection CF_AVAILABLE(10_9, 6_0); // CFBoolean - - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFPRIV__ */ - diff --git a/CFPriv.h b/CFPriv.h new file mode 120000 index 0000000..ecac436 --- /dev/null +++ b/CFPriv.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFPriv.h \ No newline at end of file diff --git a/CFPropertyList.h b/CFPropertyList.h deleted file mode 100644 index d07fa4a..0000000 --- a/CFPropertyList.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFPropertyList.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFPROPERTYLIST__) -#define __COREFOUNDATION_CFPROPERTYLIST__ 1 - -#include -#include -#include -#include -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_EMBEDDED -#include -#endif - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef CF_OPTIONS(CFOptionFlags, CFPropertyListMutabilityOptions) { - kCFPropertyListImmutable = 0, - kCFPropertyListMutableContainers, - kCFPropertyListMutableContainersAndLeaves -}; - -CF_IMPLICIT_BRIDGING_DISABLED - -/* - Creates a property list object from its XML description; xmlData should - be the raw bytes of that description, possibly the contents of an XML - file. Returns NULL if the data cannot be parsed; if the parse fails - and errorString is non-NULL, a human-readable description of the failure - is returned in errorString. It is the caller's responsibility to release - either the returned object or the error string, whichever is applicable. - - This function is deprecated. See CFPropertyListCreateWithData() for a replacement. -*/ -CF_EXPORT -CFPropertyListRef CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags mutabilityOption, CFStringRef *errorString) CF_DEPRECATED(10_0, 10_10, 2_0, 8_0, "Use CFPropertyListCreateWithData instead."); - -/* - Returns the XML description of the given object; propertyList must - be one of the supported property list types, and (for composite types - like CFArray and CFDictionary) must not contain any elements that - are not themselves of a property list type. If a non-property list - type is encountered, NULL is returned. The returned data is - appropriate for writing out to an XML file. Note that a data, not a - string, is returned because the bytes contain in them a description - of the string encoding used. - - This function is deprecated. See CFPropertyListCreateData() for a replacement. -*/ -CF_EXPORT -CFDataRef CFPropertyListCreateXMLData(CFAllocatorRef allocator, CFPropertyListRef propertyList) CF_DEPRECATED(10_0, 10_10, 2_0, 8_0, "Use CFPropertyListCreateData instead."); - -CF_IMPLICIT_BRIDGING_ENABLED - -/* - Recursively creates a copy of the given property list (so nested arrays - and dictionaries are copied as well as the top-most container). The - resulting property list has the mutability characteristics determined - by mutabilityOption. -*/ -CF_EXPORT -CFPropertyListRef CFPropertyListCreateDeepCopy(CFAllocatorRef allocator, CFPropertyListRef propertyList, CFOptionFlags mutabilityOption); - -typedef CF_ENUM(CFIndex, CFPropertyListFormat) { - kCFPropertyListOpenStepFormat = 1, - kCFPropertyListXMLFormat_v1_0 = 100, - kCFPropertyListBinaryFormat_v1_0 = 200 -}; - -/* Returns true if the object graph rooted at plist is a valid property list - * graph -- that is, no cycles, containing only plist objects, and dictionary - * keys are strings. The debugging library version spits out some messages - * to be helpful. The plist structure which is to be allowed is given by - * the format parameter. */ -CF_EXPORT -Boolean CFPropertyListIsValid(CFPropertyListRef plist, CFPropertyListFormat format); - -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_EMBEDDED -CF_IMPLICIT_BRIDGING_DISABLED - -/* Writes the bytes of a plist serialization out to the stream. The - * stream must be opened and configured -- the function simply writes - * a bunch of bytes to the stream. The output plist format can be chosen. - * Leaves the stream open, but note that reading a plist expects the - * reading stream to end wherever the writing ended, so that the - * end of the plist data can be identified. Returns the number of bytes - * written, or 0 on error. Error messages are not currently localized, but - * may be in the future, so they are not suitable for comparison. - * - * This function is deprecated. See CFPropertyListWrite() for a replacement. */ -CF_EXPORT -CFIndex CFPropertyListWriteToStream(CFPropertyListRef propertyList, CFWriteStreamRef stream, CFPropertyListFormat format, CFStringRef *errorString) CF_DEPRECATED(10_2, 10_10, 2_0, 8_0, "Use CFPropertyListWrite instead."); - - -/* Same as current function CFPropertyListCreateFromXMLData() - * but takes a stream instead of data, and works on any plist file format. - * CFPropertyListCreateFromXMLData() also works on any plist file format. - * The stream must be open and configured -- the function simply reads a bunch - * of bytes from it starting at the current location in the stream, to the END - * of the stream, which is expected to be the end of the plist, or up to the - * number of bytes given by the length parameter if it is not 0. Error messages - * are not currently localized, but may be in the future, so they are not - * suitable for comparison. - * - * This function is deprecated. See CFPropertyListCreateWithStream() for a replacement. */ -CF_EXPORT -CFPropertyListRef CFPropertyListCreateFromStream(CFAllocatorRef allocator, CFReadStreamRef stream, CFIndex streamLength, CFOptionFlags mutabilityOption, CFPropertyListFormat *format, CFStringRef *errorString) CF_DEPRECATED(10_2, 10_10, 2_0, 8_0, "Use CFPropertyListCreateWithStream instead."); - -CF_IMPLICIT_BRIDGING_ENABLED -#endif - -CF_IMPLICIT_BRIDGING_DISABLED - -enum { - kCFPropertyListReadCorruptError = 3840, // Error parsing a property list - kCFPropertyListReadUnknownVersionError = 3841, // The version number in the property list is unknown - kCFPropertyListReadStreamError = 3842, // Stream error reading a property list - kCFPropertyListWriteStreamError = 3851, // Stream error writing a property list -} CF_ENUM_AVAILABLE(10_6, 4_0); - -/* Create a property list with a CFData input. If the format parameter is non-NULL, it will be set to the format of the data after parsing is complete. The options parameter is used to specify CFPropertyListMutabilityOptions. If an error occurs while parsing the data, the return value will be NULL. Additionally, if an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. If the parse succeeds, the returned value is a reference to the new property list. It is the responsibility of the caller to release this value. - */ -CF_EXPORT -CFPropertyListRef CFPropertyListCreateWithData(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags options, CFPropertyListFormat *format, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - -#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_EMBEDDED - -/* Create and return a property list with a CFReadStream input. If the format parameter is non-NULL, it will be set to the format of the data after parsing is complete. The options parameter is used to specify CFPropertyListMutabilityOptions. The streamLength parameter specifies the number of bytes to read from the stream. Set streamLength to 0 to read until the end of the stream is detected. If an error occurs while parsing the data, the return value will be NULL. Additionally, if an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. If the parse succeeds, the returned value is a reference to the new property list. It is the responsibility of the caller to release this value. - */ -CF_EXPORT -CFPropertyListRef CFPropertyListCreateWithStream(CFAllocatorRef allocator, CFReadStreamRef stream, CFIndex streamLength, CFOptionFlags options, CFPropertyListFormat *format, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - -/* Write the bytes of a serialized property list out to a stream. The stream must be opened and configured. The format of the property list can be chosen with the format parameter. The options parameter is currently unused and should be set to 0. The return value is the number of bytes written or 0 in the case of an error. If an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. - */ -CF_EXPORT -CFIndex CFPropertyListWrite(CFPropertyListRef propertyList, CFWriteStreamRef stream, CFPropertyListFormat format, CFOptionFlags options, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - -#endif - -/* Create a CFData with the bytes of a serialized property list. The format of the property list can be chosen with the format parameter. The options parameter is currently unused and should be set to 0. If an error occurs while parsing the data, the return value will be NULL. Additionally, if an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. If the conversion succeeds, the returned value is a reference to the created data. It is the responsibility of the caller to release this value. - */ -CF_EXPORT -CFDataRef CFPropertyListCreateData(CFAllocatorRef allocator, CFPropertyListRef propertyList, CFPropertyListFormat format, CFOptionFlags options, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - -CF_IMPLICIT_BRIDGING_ENABLED - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFPROPERTYLIST__ */ - diff --git a/CFPropertyList.h b/CFPropertyList.h new file mode 120000 index 0000000..2f9e5a2 --- /dev/null +++ b/CFPropertyList.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFPropertyList.h \ No newline at end of file diff --git a/CFRunLoop.h b/CFRunLoop.h deleted file mode 100644 index 967670c..0000000 --- a/CFRunLoop.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFRunLoop.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFRUNLOOP__) -#define __COREFOUNDATION_CFRUNLOOP__ 1 - -#include -#include -#include -#include -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -#include -#endif - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct __CFRunLoop * CFRunLoopRef; - -typedef struct __CFRunLoopSource * CFRunLoopSourceRef; - -typedef struct __CFRunLoopObserver * CFRunLoopObserverRef; - -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSTimer) __CFRunLoopTimer * CFRunLoopTimerRef; - -/* Reasons for CFRunLoopRunInMode() to Return */ -enum { - kCFRunLoopRunFinished = 1, - kCFRunLoopRunStopped = 2, - kCFRunLoopRunTimedOut = 3, - kCFRunLoopRunHandledSource = 4 -}; - -/* Run Loop Observer Activities */ -typedef CF_OPTIONS(CFOptionFlags, CFRunLoopActivity) { - kCFRunLoopEntry = (1UL << 0), - kCFRunLoopBeforeTimers = (1UL << 1), - kCFRunLoopBeforeSources = (1UL << 2), - kCFRunLoopBeforeWaiting = (1UL << 5), - kCFRunLoopAfterWaiting = (1UL << 6), - kCFRunLoopExit = (1UL << 7), - kCFRunLoopAllActivities = 0x0FFFFFFFU -}; - -CF_EXPORT const CFStringRef kCFRunLoopDefaultMode; -CF_EXPORT const CFStringRef kCFRunLoopCommonModes; - -CF_EXPORT CFTypeID CFRunLoopGetTypeID(void); - -CF_EXPORT CFRunLoopRef CFRunLoopGetCurrent(void); -CF_EXPORT CFRunLoopRef CFRunLoopGetMain(void); - -CF_EXPORT CFStringRef CFRunLoopCopyCurrentMode(CFRunLoopRef rl); - -CF_EXPORT CFArrayRef CFRunLoopCopyAllModes(CFRunLoopRef rl); - -CF_EXPORT void CFRunLoopAddCommonMode(CFRunLoopRef rl, CFStringRef mode); - -CF_EXPORT CFAbsoluteTime CFRunLoopGetNextTimerFireDate(CFRunLoopRef rl, CFStringRef mode); - -CF_EXPORT void CFRunLoopRun(void); -CF_EXPORT SInt32 CFRunLoopRunInMode(CFStringRef mode, CFTimeInterval seconds, Boolean returnAfterSourceHandled); -CF_EXPORT Boolean CFRunLoopIsWaiting(CFRunLoopRef rl); -CF_EXPORT void CFRunLoopWakeUp(CFRunLoopRef rl); -CF_EXPORT void CFRunLoopStop(CFRunLoopRef rl); - -#if __BLOCKS__ -CF_EXPORT void CFRunLoopPerformBlock(CFRunLoopRef rl, CFTypeRef mode, void (^block)(void)) CF_AVAILABLE(10_6, 4_0); -#endif - -CF_EXPORT Boolean CFRunLoopContainsSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFStringRef mode); -CF_EXPORT void CFRunLoopAddSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFStringRef mode); -CF_EXPORT void CFRunLoopRemoveSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFStringRef mode); - -CF_EXPORT Boolean CFRunLoopContainsObserver(CFRunLoopRef rl, CFRunLoopObserverRef observer, CFStringRef mode); -CF_EXPORT void CFRunLoopAddObserver(CFRunLoopRef rl, CFRunLoopObserverRef observer, CFStringRef mode); -CF_EXPORT void CFRunLoopRemoveObserver(CFRunLoopRef rl, CFRunLoopObserverRef observer, CFStringRef mode); - -CF_EXPORT Boolean CFRunLoopContainsTimer(CFRunLoopRef rl, CFRunLoopTimerRef timer, CFStringRef mode); -CF_EXPORT void CFRunLoopAddTimer(CFRunLoopRef rl, CFRunLoopTimerRef timer, CFStringRef mode); -CF_EXPORT void CFRunLoopRemoveTimer(CFRunLoopRef rl, CFRunLoopTimerRef timer, CFStringRef mode); - -typedef struct { - CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); - Boolean (*equal)(const void *info1, const void *info2); - CFHashCode (*hash)(const void *info); - void (*schedule)(void *info, CFRunLoopRef rl, CFStringRef mode); - void (*cancel)(void *info, CFRunLoopRef rl, CFStringRef mode); - void (*perform)(void *info); -} CFRunLoopSourceContext; - -typedef struct { - CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); - Boolean (*equal)(const void *info1, const void *info2); - CFHashCode (*hash)(const void *info); -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) - mach_port_t (*getPort)(void *info); - void * (*perform)(void *msg, CFIndex size, CFAllocatorRef allocator, void *info); -#else - void * (*getPort)(void *info); - void (*perform)(void *info); -#endif -} CFRunLoopSourceContext1; - -CF_EXPORT CFTypeID CFRunLoopSourceGetTypeID(void); - -CF_EXPORT CFRunLoopSourceRef CFRunLoopSourceCreate(CFAllocatorRef allocator, CFIndex order, CFRunLoopSourceContext *context); - -CF_EXPORT CFIndex CFRunLoopSourceGetOrder(CFRunLoopSourceRef source); -CF_EXPORT void CFRunLoopSourceInvalidate(CFRunLoopSourceRef source); -CF_EXPORT Boolean CFRunLoopSourceIsValid(CFRunLoopSourceRef source); -CF_EXPORT void CFRunLoopSourceGetContext(CFRunLoopSourceRef source, CFRunLoopSourceContext *context); -CF_EXPORT void CFRunLoopSourceSignal(CFRunLoopSourceRef source); - -typedef struct { - CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); -} CFRunLoopObserverContext; - -typedef void (*CFRunLoopObserverCallBack)(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info); - -CF_EXPORT CFTypeID CFRunLoopObserverGetTypeID(void); - -CF_EXPORT CFRunLoopObserverRef CFRunLoopObserverCreate(CFAllocatorRef allocator, CFOptionFlags activities, Boolean repeats, CFIndex order, CFRunLoopObserverCallBack callout, CFRunLoopObserverContext *context); -#if __BLOCKS__ -CF_EXPORT CFRunLoopObserverRef CFRunLoopObserverCreateWithHandler(CFAllocatorRef allocator, CFOptionFlags activities, Boolean repeats, CFIndex order, void (^block) (CFRunLoopObserverRef observer, CFRunLoopActivity activity)) CF_AVAILABLE(10_7, 5_0); -#endif - -CF_EXPORT CFOptionFlags CFRunLoopObserverGetActivities(CFRunLoopObserverRef observer); -CF_EXPORT Boolean CFRunLoopObserverDoesRepeat(CFRunLoopObserverRef observer); -CF_EXPORT CFIndex CFRunLoopObserverGetOrder(CFRunLoopObserverRef observer); -CF_EXPORT void CFRunLoopObserverInvalidate(CFRunLoopObserverRef observer); -CF_EXPORT Boolean CFRunLoopObserverIsValid(CFRunLoopObserverRef observer); -CF_EXPORT void CFRunLoopObserverGetContext(CFRunLoopObserverRef observer, CFRunLoopObserverContext *context); - -typedef struct { - CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); -} CFRunLoopTimerContext; - -typedef void (*CFRunLoopTimerCallBack)(CFRunLoopTimerRef timer, void *info); - -CF_EXPORT CFTypeID CFRunLoopTimerGetTypeID(void); - -CF_EXPORT CFRunLoopTimerRef CFRunLoopTimerCreate(CFAllocatorRef allocator, CFAbsoluteTime fireDate, CFTimeInterval interval, CFOptionFlags flags, CFIndex order, CFRunLoopTimerCallBack callout, CFRunLoopTimerContext *context); -#if __BLOCKS__ -CF_EXPORT CFRunLoopTimerRef CFRunLoopTimerCreateWithHandler(CFAllocatorRef allocator, CFAbsoluteTime fireDate, CFTimeInterval interval, CFOptionFlags flags, CFIndex order, void (^block) (CFRunLoopTimerRef timer)) CF_AVAILABLE(10_7, 5_0); -#endif - -CF_EXPORT CFAbsoluteTime CFRunLoopTimerGetNextFireDate(CFRunLoopTimerRef timer); -CF_EXPORT void CFRunLoopTimerSetNextFireDate(CFRunLoopTimerRef timer, CFAbsoluteTime fireDate); -CF_EXPORT CFTimeInterval CFRunLoopTimerGetInterval(CFRunLoopTimerRef timer); -CF_EXPORT Boolean CFRunLoopTimerDoesRepeat(CFRunLoopTimerRef timer); -CF_EXPORT CFIndex CFRunLoopTimerGetOrder(CFRunLoopTimerRef timer); -CF_EXPORT void CFRunLoopTimerInvalidate(CFRunLoopTimerRef timer); -CF_EXPORT Boolean CFRunLoopTimerIsValid(CFRunLoopTimerRef timer); -CF_EXPORT void CFRunLoopTimerGetContext(CFRunLoopTimerRef timer, CFRunLoopTimerContext *context); - -// Setting a tolerance for a timer allows it to fire later than the scheduled fire date, improving the ability of the system to optimize for increased power savings and responsiveness. The timer may fire at any time between its scheduled fire date and the scheduled fire date plus the tolerance. The timer will not fire before the scheduled fire date. For repeating timers, the next fire date is calculated from the original fire date regardless of tolerance applied at individual fire times, to avoid drift. The default value is zero, which means no additional tolerance is applied. The system reserves the right to apply a small amount of tolerance to certain timers regardless of the value of this property. -// As the user of the timer, you will have the best idea of what an appropriate tolerance for a timer may be. A general rule of thumb, though, is to set the tolerance to at least 10% of the interval, for a repeating timer. Even a small amount of tolerance will have a significant positive impact on the power usage of your application. The system may put a maximum value of the tolerance. -CF_EXPORT CFTimeInterval CFRunLoopTimerGetTolerance(CFRunLoopTimerRef timer) CF_AVAILABLE(10_9, 7_0); -CF_EXPORT void CFRunLoopTimerSetTolerance(CFRunLoopTimerRef timer, CFTimeInterval tolerance) CF_AVAILABLE(10_9, 7_0); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFRUNLOOP__ */ - diff --git a/CFRunLoop.h b/CFRunLoop.h new file mode 120000 index 0000000..d23587d --- /dev/null +++ b/CFRunLoop.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFRunLoop.h \ No newline at end of file diff --git a/CFRuntime.h b/CFRuntime.h deleted file mode 100644 index 1eacd63..0000000 --- a/CFRuntime.h +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFRuntime.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFRUNTIME__) -#define __COREFOUNDATION_CFRUNTIME__ 1 - -#include -#include -#include - -CF_EXTERN_C_BEGIN - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) - -// GC: until we link against ObjC must use indirect functions. Overridden in CFSetupFoundationBridging -CF_EXPORT bool kCFUseCollectableAllocator; -CF_EXPORT bool (*__CFObjCIsCollectable)(void *); - -CF_INLINE Boolean _CFAllocatorIsSystemDefault(CFAllocatorRef allocator) { - if (allocator == kCFAllocatorSystemDefault) return true; - if (NULL == allocator || kCFAllocatorDefault == allocator) { - return (kCFAllocatorSystemDefault == CFAllocatorGetDefault()); - } - return false; -} - -// is GC on? -#define CF_USING_COLLECTABLE_MEMORY (kCFUseCollectableAllocator) -// is GC on and is this the GC allocator? -#define CF_IS_COLLECTABLE_ALLOCATOR(allocator) (kCFUseCollectableAllocator && (NULL == (allocator) || kCFAllocatorSystemDefault == (allocator) || 0)) -// is this allocated by the collector? -#define CF_IS_COLLECTABLE(obj) (__CFObjCIsCollectable ? __CFObjCIsCollectable((void*)obj) : false) - -#else - -#define kCFUseCollectableAllocator 0 -#define __CFObjCIsCollectable 0 - -CF_INLINE Boolean _CFAllocatorIsSystemDefault(CFAllocatorRef allocator) { - if (allocator == kCFAllocatorSystemDefault) return true; - if (NULL == allocator || kCFAllocatorDefault == allocator) { - return (kCFAllocatorSystemDefault == CFAllocatorGetDefault()); - } - return false; -} - -#define CF_USING_COLLECTABLE_MEMORY 0 -#define CF_IS_COLLECTABLE_ALLOCATOR(allocator) 0 -#define CF_IS_COLLECTABLE(obj) 0 -#endif - -enum { - _kCFRuntimeNotATypeID = 0 -}; - -enum { // Version field constants - _kCFRuntimeScannedObject = (1UL << 0), - _kCFRuntimeResourcefulObject = (1UL << 2), // tells CFRuntime to make use of the reclaim field - _kCFRuntimeCustomRefCount = (1UL << 3), // tells CFRuntime to make use of the refcount field - _kCFRuntimeRequiresAlignment = (1UL << 4), // tells CFRuntime to make use of the requiredAlignment field -}; - -typedef struct __CFRuntimeClass { - CFIndex version; - const char *className; // must be a pure ASCII string, nul-terminated - void (*init)(CFTypeRef cf); - CFTypeRef (*copy)(CFAllocatorRef allocator, CFTypeRef cf); - void (*finalize)(CFTypeRef cf); - Boolean (*equal)(CFTypeRef cf1, CFTypeRef cf2); - CFHashCode (*hash)(CFTypeRef cf); - CFStringRef (*copyFormattingDesc)(CFTypeRef cf, CFDictionaryRef formatOptions); // return str with retain - CFStringRef (*copyDebugDesc)(CFTypeRef cf); // return str with retain - -#define CF_RECLAIM_AVAILABLE 1 - void (*reclaim)(CFTypeRef cf); // Or in _kCFRuntimeResourcefulObject in the .version to indicate this field should be used - -#define CF_REFCOUNT_AVAILABLE 1 - uint32_t (*refcount)(intptr_t op, CFTypeRef cf); // Or in _kCFRuntimeCustomRefCount in the .version to indicate this field should be used - // this field must be non-NULL when _kCFRuntimeCustomRefCount is in the .version field - // - if the callback is passed 1 in 'op' it should increment the 'cf's reference count and return 0 - // - if the callback is passed 0 in 'op' it should return the 'cf's reference count, up to 32 bits - // - if the callback is passed -1 in 'op' it should decrement the 'cf's reference count; if it is now zero, 'cf' should be cleaned up and deallocated (the finalize callback above will NOT be called unless the process is running under GC, and CF does not deallocate the memory for you; if running under GC, finalize should do the object tear-down and free the object memory); then return 0 - // remember to use saturation arithmetic logic and stop incrementing and decrementing when the ref count hits UINT32_MAX, or you will have a security bug - // remember that reference count incrementing/decrementing must be done thread-safely/atomically - // objects should be created/initialized with a custom ref-count of 1 by the class creation functions - // do not attempt to use any bits within the CFRuntimeBase for your reference count; store that in some additional field in your CF object - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#define CF_REQUIRED_ALIGNMENT_AVAILABLE 1 - uintptr_t requiredAlignment; // Or in _kCFRuntimeRequiresAlignment in the .version field to indicate this field should be used; the allocator to _CFRuntimeCreateInstance() will be ignored in this case; if this is less than the minimum alignment the system supports, you'll get higher alignment; if this is not an alignment the system supports (e.g., most systems will only support powers of two, or if it is too high), the result (consequences) will be up to CF or the system to decide - -} CFRuntimeClass; - -#define RADAR_5115468_FIXED 1 - -/* Note that CF runtime class registration and unregistration is not currently - * thread-safe, which should not currently be a problem, as long as unregistration - * is done only when valid to do so. - */ - -CF_EXPORT CFTypeID _CFRuntimeRegisterClass(const CFRuntimeClass * const cls); - /* Registers a new class with the CF runtime. Pass in a - * pointer to a CFRuntimeClass structure. The pointer is - * remembered by the CF runtime -- the structure is NOT - * copied. - * - * - version field must be zero currently. - * - className field points to a null-terminated C string - * containing only ASCII (0 - 127) characters; this field - * may NOT be NULL. - * - init field points to a function which classes can use to - * apply some generic initialization to instances as they - * are created; this function is called by both - * _CFRuntimeCreateInstance and _CFRuntimeInitInstance; if - * this field is NULL, no function is called; the instance - * has been initialized enough that the polymorphic funcs - * CFGetTypeID(), CFRetain(), CFRelease(), CFGetRetainCount(), - * and CFGetAllocator() are valid on it when the init - * function if any is called. - * - copy field should always be NULL. Generic copying of CF - * objects has never been defined (and is unlikely). - * - finalize field points to a function which destroys an - * instance when the retain count has fallen to zero; if - * this is NULL, finalization does nothing. Note that if - * the class-specific functions which create or initialize - * instances more fully decide that a half-initialized - * instance must be destroyed, the finalize function for - * that class has to be able to deal with half-initialized - * instances. The finalize function should NOT destroy the - * memory for the instance itself; that is done by the - * CF runtime after this finalize callout returns. - * - equal field points to an equality-testing function; this - * field may be NULL, in which case only pointer/reference - * equality is performed on instances of this class. - * Pointer equality is tested, and the type IDs are checked - * for equality, before this function is called (so, the - * two instances are not pointer-equal but are of the same - * class before this function is called). - * NOTE: the equal function must implement an immutable - * equality relation, satisfying the reflexive, symmetric, - * and transitive properties, and remains the same across - * time and immutable operations (that is, if equal(A,B) at - * some point, then later equal(A,B) provided neither - * A or B has been mutated). - * - hash field points to a hash-code-computing function for - * instances of this class; this field may be NULL in which - * case the pointer value of an instance is converted into - * a hash. - * NOTE: the hash function and equal function must satisfy - * the relationship "equal(A,B) implies hash(A) == hash(B)"; - * that is, if two instances are equal, their hash codes must - * be equal too. (However, the converse is not true!) - * - copyFormattingDesc field points to a function returning a - * CFStringRef with a human-readable description of the - * instance; if this is NULL, the type does not have special - * human-readable string-formats. - * - copyDebugDesc field points to a function returning a - * CFStringRef with a debugging description of the instance; - * if this is NULL, a simple description is generated. - * - * This function returns _kCFRuntimeNotATypeID on failure, or - * on success, returns the CFTypeID for the new class. This - * CFTypeID is what the class uses to allocate or initialize - * instances of the class. It is also returned from the - * conventional *GetTypeID() function, which returns the - * class's CFTypeID so that clients can compare the - * CFTypeID of instances with that of a class. - * - * The function to compute a human-readable string is very - * optional, and is really only interesting for classes, - * like strings or numbers, where it makes sense to format - * the instance using just its contents. - */ - -CF_EXPORT const CFRuntimeClass * _CFRuntimeGetClassWithTypeID(CFTypeID typeID); - /* Returns the pointer to the CFRuntimeClass which was - * assigned the specified CFTypeID. - */ - -CF_EXPORT void _CFRuntimeUnregisterClassWithTypeID(CFTypeID typeID); - /* Unregisters the class with the given type ID. It is - * undefined whether type IDs are reused or not (expect - * that they will be). - * - * Whether or not unregistering the class is a good idea or - * not is not CF's responsibility. In particular you must - * be quite sure all instances are gone, and there are no - * valid weak refs to such in other threads. - */ - -/* All CF "instances" start with this structure. Never refer to - * these fields directly -- they are for CF's use and may be added - * to or removed or change format without warning. Binary - * compatibility for uses of this struct is not guaranteed from - * release to release. - */ -typedef struct __CFRuntimeBase { - uintptr_t _cfisa; - uint8_t _cfinfo[4]; -#if __LP64__ - uint32_t _rc; -#endif -} CFRuntimeBase; - -#if __BIG_ENDIAN__ -#define INIT_CFRUNTIME_BASE(...) {0, {0, 0, 0, 0x80}} -#else -#define INIT_CFRUNTIME_BASE(...) {0, {0x80, 0, 0, 0}} -#endif - -CF_EXPORT CFTypeRef _CFRuntimeCreateInstance(CFAllocatorRef allocator, CFTypeID typeID, CFIndex extraBytes, unsigned char *category); - /* Creates a new CF instance of the class specified by the - * given CFTypeID, using the given allocator, and returns it. - * If the allocator returns NULL, this function returns NULL. - * A CFRuntimeBase structure is initialized at the beginning - * of the returned instance. extraBytes is the additional - * number of bytes to allocate for the instance (BEYOND that - * needed for the CFRuntimeBase). If the specified CFTypeID - * is unknown to the CF runtime, this function returns NULL. - * No part of the new memory other than base header is - * initialized (the extra bytes are not zeroed, for example). - * All instances created with this function must be destroyed - * only through use of the CFRelease() function -- instances - * must not be destroyed by using CFAllocatorDeallocate() - * directly, even in the initialization or creation functions - * of a class. Pass NULL for the category parameter. - */ - -CF_EXPORT void _CFRuntimeSetInstanceTypeID(CFTypeRef cf, CFTypeID typeID); - /* This function changes the typeID of the given instance. - * If the specified CFTypeID is unknown to the CF runtime, - * this function does nothing. This function CANNOT be used - * to initialize an instance. It is for advanced usages such - * as faulting. You cannot change the CFTypeID of an object - * of a _kCFRuntimeCustomRefCount class, or to a - * _kCFRuntimeCustomRefCount class. - */ - -CF_EXPORT void _CFRuntimeInitStaticInstance(void *memory, CFTypeID typeID); - /* This function initializes a memory block to be a constant - * (unreleaseable) CF object of the given typeID. - * If the specified CFTypeID is unknown to the CF runtime, - * this function does nothing. The memory block should - * be a chunk of in-binary writeable static memory, and at - * least as large as sizeof(CFRuntimeBase) on the platform - * the code is being compiled for. The init function of the - * CFRuntimeClass is invoked on the memory as well, if the - * class has one. Static instances cannot be initialized to - * _kCFRuntimeCustomRefCount classes. - */ -#define CF_HAS_INIT_STATIC_INSTANCE 1 - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFRUNTIME__ */ - diff --git a/CFRuntime.h b/CFRuntime.h new file mode 120000 index 0000000..e1453d6 --- /dev/null +++ b/CFRuntime.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFRuntime.h \ No newline at end of file diff --git a/CFSet.h b/CFSet.h deleted file mode 100644 index e555997..0000000 --- a/CFSet.h +++ /dev/null @@ -1,509 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFSet.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ -/*! - @header CFSet - CFSet implements a container which stores unique values. -*/ - -#if !defined(__COREFOUNDATION_CFSET__) -#define __COREFOUNDATION_CFSET__ 1 - -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -/*! - @typedef CFSetRetainCallBack - Type of the callback function used by CFSets for retaining values. - @param allocator The allocator of the CFSet. - @param value The value to retain. - @result The value to store in the set, which is usually the value - parameter passed to this callback, but may be a different - value if a different value should be stored in the set. -*/ -typedef const void * (*CFSetRetainCallBack)(CFAllocatorRef allocator, const void *value); - -/*! - @typedef CFSetReleaseCallBack - Type of the callback function used by CFSets for releasing a retain on values. - @param allocator The allocator of the CFSet. - @param value The value to release. -*/ -typedef void (*CFSetReleaseCallBack)(CFAllocatorRef allocator, const void *value); - -/*! - @typedef CFSetCopyDescriptionCallBack - Type of the callback function used by CFSets for describing values. - @param value The value to describe. - @result A description of the specified value. -*/ -typedef CFStringRef (*CFSetCopyDescriptionCallBack)(const void *value); - -/*! - @typedef CFSetEqualCallBack - Type of the callback function used by CFSets for comparing values. - @param value1 The first value to compare. - @param value2 The second value to compare. - @result True if the values are equal, otherwise false. -*/ -typedef Boolean (*CFSetEqualCallBack)(const void *value1, const void *value2); - -/*! - @typedef CFSetHashCallBack - Type of the callback function used by CFSets for hashing values. - @param value The value to hash. - @result The hash of the value. -*/ -typedef CFHashCode (*CFSetHashCallBack)(const void *value); - -/*! - @typedef CFSetCallBacks - Structure containing the callbacks of a CFSet. - @field version The version number of the structure type being passed - in as a parameter to the CFSet creation functions. This - structure is version 0. - @field retain The callback used to add a retain for the set on - values as they are put into the set. This callback returns - the value to store in the set, which is usually the value - parameter passed to this callback, but may be a different - value if a different value should be stored in the set. - The set's allocator is passed as the first argument. - @field release The callback used to remove a retain previously added - for the set from values as they are removed from the - set. The set's allocator is passed as the first - argument. - @field copyDescription The callback used to create a descriptive - string representation of each value in the set. This is - used by the CFCopyDescription() function. - @field equal The callback used to compare values in the set for - equality for some operations. - @field hash The callback used to compare values in the set for - uniqueness for some operations. -*/ -typedef struct { - CFIndex version; - CFSetRetainCallBack retain; - CFSetReleaseCallBack release; - CFSetCopyDescriptionCallBack copyDescription; - CFSetEqualCallBack equal; - CFSetHashCallBack hash; -} CFSetCallBacks; - -/*! - @constant kCFTypeSetCallBacks - Predefined CFSetCallBacks structure containing a set of callbacks - appropriate for use when the values in a CFSet are all CFTypes. -*/ -CF_EXPORT -const CFSetCallBacks kCFTypeSetCallBacks; - -/*! - @constant kCFCopyStringSetCallBacks - Predefined CFSetCallBacks structure containing a set of callbacks - appropriate for use when the values in a CFSet should be copies - of a CFString. -*/ -CF_EXPORT -const CFSetCallBacks kCFCopyStringSetCallBacks; - -/*! - @typedef CFSetApplierFunction - Type of the callback function used by the apply functions of - CFSets. - @param value The current value from the set. - @param context The user-defined context parameter given to the apply - function. -*/ -typedef void (*CFSetApplierFunction)(const void *value, void *context); - -/*! - @typedef CFSetRef - This is the type of a reference to immutable CFSets. -*/ -typedef const struct CF_BRIDGED_TYPE(NSSet) __CFSet * CFSetRef; - -/*! - @typedef CFMutableSetRef - This is the type of a reference to mutable CFSets. -*/ -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableSet) __CFSet * CFMutableSetRef; - -/*! - @function CFSetGetTypeID - Returns the type identifier of all CFSet instances. -*/ -CF_EXPORT -CFTypeID CFSetGetTypeID(void); - -/*! - @function CFSetCreate - Creates a new immutable set with the given values. - @param allocator The CFAllocator which should be used to allocate - memory for the set and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param values A C array of the pointer-sized values to be in the - set. This C array is not changed or freed by this function. - If this parameter is not a valid pointer to a C array of at - least numValues pointers, the behavior is undefined. - @param numValues The number of values to copy from the values C - array into the CFSet. This number will be the count of the - set. If this parameter is zero, negative, or greater than - the number of values actually in the values C array, the - behavior is undefined. - @param callBacks A C pointer to a CFSetCallBacks structure - initialized with the callbacks for the set to use on each - value in the set. A copy of the contents of the - callbacks structure is made, so that a pointer to a - structure on the stack can be passed in, or can be reused - for multiple set creations. If the version field of this - callbacks structure is not one of the defined ones for - CFSet, the behavior is undefined. The retain field may be - NULL, in which case the CFSet will do nothing to add a - retain to the contained values for the set. The release - field may be NULL, in which case the CFSet will do nothing - to remove the set's retain (if any) on the values when the - set is destroyed. If the copyDescription field is NULL, - the set will create a simple description for the value. If - the equal field is NULL, the set will use pointer equality - to test for equality of values. The hash field may be NULL, - in which case the CFSet will determine uniqueness by pointer - equality. This callbacks parameter - itself may be NULL, which is treated as if a valid structure - of version 0 with all fields NULL had been passed in. - Otherwise, if any of the fields are not valid pointers to - functions of the correct type, or this parameter is not a - valid pointer to a CFSetCallBacks callbacks structure, - the behavior is undefined. If any of the values put into the - set is not one understood by one of the callback functions - the behavior when that callback function is used is - undefined. - @result A reference to the new immutable CFSet. -*/ -CF_EXPORT -CFSetRef CFSetCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFSetCallBacks *callBacks); - -/*! - @function CFSetCreateCopy - Creates a new immutable set with the values from the given set. - @param allocator The CFAllocator which should be used to allocate - memory for the set and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param theSet The set which is to be copied. The values from the - set are copied as pointers into the new set (that is, - the values themselves are copied, not that which the values - point to, if anything). However, the values are also - retained by the new set. The count of the new set will - be the same as the copied set. The new set uses the same - callbacks as the set to be copied. If this parameter is - not a valid CFSet, the behavior is undefined. - @result A reference to the new immutable CFSet. -*/ -CF_EXPORT -CFSetRef CFSetCreateCopy(CFAllocatorRef allocator, CFSetRef theSet); - -/*! - @function CFSetCreateMutable - Creates a new empty mutable set. - @param allocator The CFAllocator which should be used to allocate - memory for the set and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param capacity A hint about the number of values that will be held - by the CFSet. Pass 0 for no hint. The implementation may - ignore this hint, or may use it to optimize various - operations. A set's actual capacity is only limited by - address space and available memory constraints). If this - parameter is negative, the behavior is undefined. - @param callBacks A C pointer to a CFSetCallBacks structure - initialized with the callbacks for the set to use on each - value in the set. A copy of the contents of the - callbacks structure is made, so that a pointer to a - structure on the stack can be passed in, or can be reused - for multiple set creations. If the version field of this - callbacks structure is not one of the defined ones for - CFSet, the behavior is undefined. The retain field may be - NULL, in which case the CFSet will do nothing to add a - retain to the contained values for the set. The release - field may be NULL, in which case the CFSet will do nothing - to remove the set's retain (if any) on the values when the - set is destroyed. If the copyDescription field is NULL, - the set will create a simple description for the value. If - the equal field is NULL, the set will use pointer equality - to test for equality of values. The hash field may be NULL, - in which case the CFSet will determine uniqueness by pointer - equality. This callbacks parameter - itself may be NULL, which is treated as if a valid structure - of version 0 with all fields NULL had been passed in. - Otherwise, if any of the fields are not valid pointers to - functions of the correct type, or this parameter is not a - valid pointer to a CFSetCallBacks callbacks structure, - the behavior is undefined. If any of the values put into the - set is not one understood by one of the callback functions - the behavior when that callback function is used is - undefined. - @result A reference to the new mutable CFSet. -*/ -CF_EXPORT -CFMutableSetRef CFSetCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFSetCallBacks *callBacks); - -/*! - @function CFSetCreateMutableCopy - Creates a new immutable set with the values from the given set. - @param allocator The CFAllocator which should be used to allocate - memory for the set and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param capacity A hint about the number of values that will be held - by the CFSet. Pass 0 for no hint. The implementation may - ignore this hint, or may use it to optimize various - operations. A set's actual capacity is only limited by - address space and available memory constraints). - This parameter must be greater than or equal - to the count of the set which is to be copied, or the - behavior is undefined. If this parameter is negative, the - behavior is undefined. - @param theSet The set which is to be copied. The values from the - set are copied as pointers into the new set (that is, - the values themselves are copied, not that which the values - point to, if anything). However, the values are also - retained by the new set. The count of the new set will - be the same as the copied set. The new set uses the same - callbacks as the set to be copied. If this parameter is - not a valid CFSet, the behavior is undefined. - @result A reference to the new mutable CFSet. -*/ -CF_EXPORT -CFMutableSetRef CFSetCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFSetRef theSet); - -/*! - @function CFSetGetCount - Returns the number of values currently in the set. - @param theSet The set to be queried. If this parameter is not a valid - CFSet, the behavior is undefined. - @result The number of values in the set. -*/ -CF_EXPORT -CFIndex CFSetGetCount(CFSetRef theSet); - -/*! - @function CFSetGetCountOfValue - Counts the number of times the given value occurs in the set. Since - sets by definition contain only one instance of a value, this function - is synonymous to CFSetContainsValue. - @param theSet The set to be searched. If this parameter is not a - valid CFSet, the behavior is undefined. - @param value The value for which to find matches in the set. The - equal() callback provided when the set was created is - used to compare. If the equal() callback was NULL, pointer - equality (in C, ==) is used. If value, or any of the values - in the set, are not understood by the equal() callback, - the behavior is undefined. - @result The number of times the given value occurs in the set. -*/ -CF_EXPORT -CFIndex CFSetGetCountOfValue(CFSetRef theSet, const void *value); - -/*! - @function CFSetContainsValue - Reports whether or not the value is in the set. - @param theSet The set to be searched. If this parameter is not a - valid CFSet, the behavior is undefined. - @param value The value for which to find matches in the set. The - equal() callback provided when the set was created is - used to compare. If the equal() callback was NULL, pointer - equality (in C, ==) is used. If value, or any of the values - in the set, are not understood by the equal() callback, - the behavior is undefined. - @result true, if the value is in the set, otherwise false. -*/ -CF_EXPORT -Boolean CFSetContainsValue(CFSetRef theSet, const void *value); - -/*! - @function CFSetGetValue - Retrieves a value in the set which hashes the same as the specified value. - @param theSet The set to be queried. If this parameter is not a - valid CFSet, the behavior is undefined. - @param value The value to retrieve. The equal() callback provided when - the set was created is used to compare. If the equal() callback - was NULL, pointer equality (in C, ==) is used. If a value, or - any of the values in the set, are not understood by the equal() - callback, the behavior is undefined. - @result The value in the set with the given hash. -*/ -CF_EXPORT -const void *CFSetGetValue(CFSetRef theSet, const void *value); - -/*! - @function CFSetGetValueIfPresent - Retrieves a value in the set which hashes the same as the specified value, - if present. - @param theSet The set to be queried. If this parameter is not a - valid CFSet, the behavior is undefined. - @param candidate This value is hashed and compared with values in the - set to determine which value to retrieve. The equal() callback provided when - the set was created is used to compare. If the equal() callback - was NULL, pointer equality (in C, ==) is used. If a value, or - any of the values in the set, are not understood by the equal() - callback, the behavior is undefined. - @param value A pointer to memory which should be filled with the - pointer-sized value if a matching value is found. If no - match is found, the contents of the storage pointed to by - this parameter are undefined. This parameter may be NULL, - in which case the value from the dictionary is not returned - (but the return value of this function still indicates - whether or not the value was present). - @result True if the value was present in the set, otherwise false. -*/ -CF_EXPORT -Boolean CFSetGetValueIfPresent(CFSetRef theSet, const void *candidate, const void **value); - -/*! - @function CFSetGetValues - Fills the buffer with values from the set. - @param theSet The set to be queried. If this parameter is not a - valid CFSet, the behavior is undefined. - @param values A C array of pointer-sized values to be filled with - values from the set. The values in the C array are ordered - in the same order in which they appear in the set. If this - parameter is not a valid pointer to a C array of at least - CFSetGetCount() pointers, the behavior is undefined. -*/ -CF_EXPORT -void CFSetGetValues(CFSetRef theSet, const void **values); - -/*! - @function CFSetApplyFunction - Calls a function once for each value in the set. - @param theSet The set to be operated upon. If this parameter is not - a valid CFSet, the behavior is undefined. - @param applier The callback function to call once for each value in - the given set. If this parameter is not a - pointer to a function of the correct prototype, the behavior - is undefined. If there are values in the set which the - applier function does not expect or cannot properly apply - to, the behavior is undefined. - @param context A pointer-sized user-defined value, which is passed - as the second parameter to the applier function, but is - otherwise unused by this function. If the context is not - what is expected by the applier function, the behavior is - undefined. -*/ -CF_EXPORT -void CFSetApplyFunction(CFSetRef theSet, CFSetApplierFunction applier, void *context); - -/*! - @function CFSetAddValue - Adds the value to the set if it is not already present. - @param theSet The set to which the value is to be added. If this - parameter is not a valid mutable CFSet, the behavior is - undefined. - @param value The value to add to the set. The value is retained by - the set using the retain callback provided when the set - was created. If the value is not of the sort expected by the - retain callback, the behavior is undefined. The count of the - set is increased by one. -*/ -CF_EXPORT -void CFSetAddValue(CFMutableSetRef theSet, const void *value); - -/*! - @function CFSetReplaceValue - Replaces the value in the set if it is present. - @param theSet The set to which the value is to be replaced. If this - parameter is not a valid mutable CFSet, the behavior is - undefined. - @param value The value to replace in the set. The equal() callback provided when - the set was created is used to compare. If the equal() callback - was NULL, pointer equality (in C, ==) is used. If a value, or - any of the values in the set, are not understood by the equal() - callback, the behavior is undefined. The value is retained by - the set using the retain callback provided when the set - was created. If the value is not of the sort expected by the - retain callback, the behavior is undefined. The count of the - set is increased by one. -*/ -CF_EXPORT -void CFSetReplaceValue(CFMutableSetRef theSet, const void *value); - -/*! - @function CFSetSetValue - Replaces the value in the set if it is present, or adds the value to - the set if it is absent. - @param theSet The set to which the value is to be replaced. If this - parameter is not a valid mutable CFSet, the behavior is - undefined. - @param value The value to set in the CFSet. The equal() callback provided when - the set was created is used to compare. If the equal() callback - was NULL, pointer equality (in C, ==) is used. If a value, or - any of the values in the set, are not understood by the equal() - callback, the behavior is undefined. The value is retained by - the set using the retain callback provided when the set - was created. If the value is not of the sort expected by the - retain callback, the behavior is undefined. The count of the - set is increased by one. -*/ -CF_EXPORT -void CFSetSetValue(CFMutableSetRef theSet, const void *value); - -/*! - @function CFSetRemoveValue - Removes the specified value from the set. - @param theSet The set from which the value is to be removed. - If this parameter is not a valid mutable CFSet, - the behavior is undefined. - @param value The value to remove. The equal() callback provided when - the set was created is used to compare. If the equal() callback - was NULL, pointer equality (in C, ==) is used. If a value, or - any of the values in the set, are not understood by the equal() - callback, the behavior is undefined. -*/ -CF_EXPORT -void CFSetRemoveValue(CFMutableSetRef theSet, const void *value); - -/*! - @function CFSetRemoveAllValues - Removes all the values from the set, making it empty. - @param theSet The set from which all of the values are to be - removed. If this parameter is not a valid mutable CFSet, - the behavior is undefined. -*/ -CF_EXPORT -void CFSetRemoveAllValues(CFMutableSetRef theSet); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFSET__ */ - diff --git a/CFSet.h b/CFSet.h new file mode 120000 index 0000000..7375863 --- /dev/null +++ b/CFSet.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFSet.h \ No newline at end of file diff --git a/CFSocket.h b/CFSocket.h deleted file mode 100644 index 1923a7f..0000000 --- a/CFSocket.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFSocket.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSOCKET__) -#define __COREFOUNDATION_CFSOCKET__ 1 - -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct __CFSocket * CFSocketRef; - -/* A CFSocket contains a native socket within a structure that can -be used to read from the socket in the background and make the data -thus read available using a runloop source. The callback used for -this may be of three types, as specified by the callBackTypes -argument when creating the CFSocket. - -If kCFSocketReadCallBack is used, then data will not be -automatically read, but the callback will be called when data -is available to be read, or a new child socket is waiting to be -accepted. - -If kCFSocketAcceptCallBack is used, then new child sockets will be -accepted and passed to the callback, with the data argument being -a pointer to a CFSocketNativeHandle. This is usable only with -connection rendezvous sockets. - -If kCFSocketDataCallBack is used, then data will be read in chunks -in the background and passed to the callback, with the data argument -being a CFDataRef. - -These three types are mutually exclusive, but any one of them may -have kCFSocketConnectCallBack added to it, if the socket will be -used to connect in the background. Connect in the background occurs -if CFSocketConnectToAddress is called with a negative timeout -value, in which case the call returns immediately, and a -kCFSocketConnectCallBack is generated when the connect finishes. -In this case the data argument is either NULL, or a pointer to -an SInt32 error code if the connect failed. kCFSocketConnectCallBack -will never be sent more than once for a given socket. - -The callback types may also have kCFSocketWriteCallBack added to -them, if large amounts of data are to be sent rapidly over the -socket and notification is desired when there is space in the -kernel buffers so that the socket is writable again. - -With a connection-oriented socket, if the connection is broken from the -other end, then one final kCFSocketReadCallBack or kCFSocketDataCallBack -will occur. In the case of kCFSocketReadCallBack, the underlying socket -will have 0 bytes available to read. In the case of kCFSocketDataCallBack, -the data argument will be a CFDataRef of length 0. - -There are socket flags that may be set to control whether callbacks of -a given type are automatically reenabled after they are triggered, and -whether the underlying native socket will be closed when the CFSocket -is invalidated. By default read, accept, and data callbacks are -automatically reenabled; write callbacks are not, and connect callbacks -may not be, since they are sent once only. Be careful about automatically -reenabling read and write callbacks, since this implies that the -callbacks will be sent repeatedly if the socket remains readable or -writable respectively. Be sure to set these flags only for callbacks -that your CFSocket actually possesses; the result of setting them for -other callback types is undefined. - -Individual callbacks may also be enabled and disabled manually, whether -they are automatically reenabled or not. If they are not automatically -reenabled, then they will need to be manually reenabled when the callback -is ready to be received again (and not sooner). Even if they are -automatically reenabled, there may be occasions when it will be useful -to be able to manually disable them temporarily and then reenable them. -Be sure to enable and disable only callbacks that your CFSocket actually -possesses; the result of enabling and disabling other callback types is -undefined. - -By default the underlying native socket will be closed when the CFSocket -is invalidated, but it will not be if kCFSocketCloseOnInvalidate is -turned off. This can be useful in order to destroy a CFSocket but -continue to use the underlying native socket. The CFSocket must -still be invalidated when it will no longer be used. Do not in -either case close the underlying native socket without invalidating -the CFSocket. - -Addresses are stored as CFDatas containing a struct sockaddr -appropriate for the protocol family; make sure that all fields are -filled in properly when passing in an address. - -*/ - -/* Values for CFSocketError */ -typedef CF_ENUM(CFIndex, CFSocketError) { - kCFSocketSuccess = 0, - kCFSocketError = -1L, - kCFSocketTimeout = -2L -}; - -typedef struct { - SInt32 protocolFamily; - SInt32 socketType; - SInt32 protocol; - CFDataRef address; -} CFSocketSignature; - -/* Values for CFSocketCallBackType */ -typedef CF_OPTIONS(CFOptionFlags, CFSocketCallBackType) { - kCFSocketNoCallBack = 0, - kCFSocketReadCallBack = 1, - kCFSocketAcceptCallBack = 2, - kCFSocketDataCallBack = 3, - kCFSocketConnectCallBack = 4, - kCFSocketWriteCallBack = 8 -}; - -/* Socket flags */ -enum { - kCFSocketAutomaticallyReenableReadCallBack = 1, - kCFSocketAutomaticallyReenableAcceptCallBack = 2, - kCFSocketAutomaticallyReenableDataCallBack = 3, - kCFSocketAutomaticallyReenableWriteCallBack = 8, - kCFSocketLeaveErrors CF_ENUM_AVAILABLE(10_5, 2_0) = 64, - kCFSocketCloseOnInvalidate = 128 -}; - -typedef void (*CFSocketCallBack)(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info); -/* If the callback wishes to keep hold of address or data after the point that it returns, then it must copy them. */ - -typedef struct { - CFIndex version; - void * info; - const void *(*retain)(const void *info); - void (*release)(const void *info); - CFStringRef (*copyDescription)(const void *info); -} CFSocketContext; - -#if TARGET_OS_WIN32 -typedef uintptr_t CFSocketNativeHandle; -#else -typedef int CFSocketNativeHandle; -#endif - -CF_EXPORT CFTypeID CFSocketGetTypeID(void); - -CF_EXPORT CFSocketRef CFSocketCreate(CFAllocatorRef allocator, SInt32 protocolFamily, SInt32 socketType, SInt32 protocol, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context); -CF_EXPORT CFSocketRef CFSocketCreateWithNative(CFAllocatorRef allocator, CFSocketNativeHandle sock, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context); -CF_EXPORT CFSocketRef CFSocketCreateWithSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context); -/* CFSocketCreateWithSocketSignature() creates a socket of the requested type and binds its address (using CFSocketSetAddress()) to the requested address. If this fails, it returns NULL. */ -CF_EXPORT CFSocketRef CFSocketCreateConnectedToSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context, CFTimeInterval timeout); -/* CFSocketCreateConnectedToSocketSignature() creates a socket suitable for connecting to the requested type and address, and connects it (using CFSocketConnectToAddress()). If this fails, it returns NULL. */ - -CF_EXPORT CFSocketError CFSocketSetAddress(CFSocketRef s, CFDataRef address); -CF_EXPORT CFSocketError CFSocketConnectToAddress(CFSocketRef s, CFDataRef address, CFTimeInterval timeout); -CF_EXPORT void CFSocketInvalidate(CFSocketRef s); - -CF_EXPORT Boolean CFSocketIsValid(CFSocketRef s); -CF_EXPORT CFDataRef CFSocketCopyAddress(CFSocketRef s); -CF_EXPORT CFDataRef CFSocketCopyPeerAddress(CFSocketRef s); -CF_EXPORT void CFSocketGetContext(CFSocketRef s, CFSocketContext *context); -CF_EXPORT CFSocketNativeHandle CFSocketGetNative(CFSocketRef s); - -CF_EXPORT CFRunLoopSourceRef CFSocketCreateRunLoopSource(CFAllocatorRef allocator, CFSocketRef s, CFIndex order); - -CF_EXPORT CFOptionFlags CFSocketGetSocketFlags(CFSocketRef s); -CF_EXPORT void CFSocketSetSocketFlags(CFSocketRef s, CFOptionFlags flags); -CF_EXPORT void CFSocketDisableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes); -CF_EXPORT void CFSocketEnableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes); - - -/* For convenience, a function is provided to send data using the socket with a timeout. The timeout will be used only if the specified value is positive. The address should be left NULL if the socket is already connected. */ -CF_EXPORT CFSocketError CFSocketSendData(CFSocketRef s, CFDataRef address, CFDataRef data, CFTimeInterval timeout); - -/* Generic name registry functionality (CFSocketRegisterValue, -CFSocketCopyRegisteredValue) allows the registration of any property -list type. Functions specific to CFSockets (CFSocketRegisterSocketData, -CFSocketCopyRegisteredSocketData) register a CFData containing the -components of a socket signature (protocol family, socket type, -protocol, and address). In each function the nameServerSignature -may be NULL, or any component of it may be 0, to use default values -(TCP, INADDR_LOOPBACK, port as set). Name registration servers might -not allow registration with other than TCP and INADDR_LOOPBACK. -The actual address of the server responding to a query may be obtained -by using the nameServerAddress argument. This address, the address -returned by CFSocketCopyRegisteredSocketSignature, and the value -returned by CFSocketCopyRegisteredValue must (if non-null) be released -by the caller. CFSocketUnregister removes any registration associated -with the specified name. -*/ - -CF_EXPORT CFSocketError CFSocketRegisterValue(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, CFPropertyListRef value); -CF_EXPORT CFSocketError CFSocketCopyRegisteredValue(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, CFPropertyListRef *value, CFDataRef *nameServerAddress); - -CF_EXPORT CFSocketError CFSocketRegisterSocketSignature(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, const CFSocketSignature *signature); -CF_EXPORT CFSocketError CFSocketCopyRegisteredSocketSignature(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, CFSocketSignature *signature, CFDataRef *nameServerAddress); - -CF_EXPORT CFSocketError CFSocketUnregister(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name); - -CF_EXPORT void CFSocketSetDefaultNameRegistryPortNumber(UInt16 port); -CF_EXPORT UInt16 CFSocketGetDefaultNameRegistryPortNumber(void); - -/* Constants used in name registry server communications */ -CF_EXPORT const CFStringRef kCFSocketCommandKey; -CF_EXPORT const CFStringRef kCFSocketNameKey; -CF_EXPORT const CFStringRef kCFSocketValueKey; -CF_EXPORT const CFStringRef kCFSocketResultKey; -CF_EXPORT const CFStringRef kCFSocketErrorKey; -CF_EXPORT const CFStringRef kCFSocketRegisterCommand; -CF_EXPORT const CFStringRef kCFSocketRetrieveCommand; - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFSOCKET__ */ - diff --git a/CFSocket.h b/CFSocket.h new file mode 120000 index 0000000..88ee44e --- /dev/null +++ b/CFSocket.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFSocket.h \ No newline at end of file diff --git a/CFStorage.h b/CFStorage.h deleted file mode 100644 index 4cddf86..0000000 --- a/CFStorage.h +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFStorage.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ -/*! - @header CFStorage -CFStorage stores an array of arbitrary-sized values. There are no callbacks; -all that is provided about the values is the size, and the appropriate number -of bytes are copied in and out of the CFStorage. - -CFStorage uses a balanced tree to store the values, and is most appropriate -for situations where potentially a large number values (more than a hundred -bytes' worth) will be stored and there will be a lot of editing (insertions and deletions). - -Getting to an item is O(log n), although caching the last result often reduces this -to a constant time. - -The overhead of CFStorage is 48 bytes. There is no per item overhead; the -non-leaf nodes in the tree cost 20 bytes each, and the worst case extra -capacity (unused space in the leaves) is 12%, typically much less. - -Because CFStorage does not necessarily use a single block of memory to store the values, -when you ask for a value, you get back the pointer to the value and optionally -the range of other values that are consecutive and thus reachable as if the -storage was a single block. -*/ - -#if !defined(__COREFOUNDATION_CFSTORAGE__) -#define __COREFOUNDATION_CFSTORAGE__ 1 - -#include - -typedef CF_OPTIONS(CFOptionFlags, CFStorageEnumerationOptionFlags) { - kCFStorageEnumerationConcurrent = (1UL << 0) /* Allow enumeration to proceed concurrently */ -}; - -CF_EXTERN_C_BEGIN - -/*! - @typedef CFStorageRef - This is the type of a reference to a CFStorage instance. -*/ -typedef struct __CFStorage *CFStorageRef; - -/*! - @typedef CFStorageApplierFunction - Type of the callback function used by the apply functions of - CFStorage. - @param value The current value from the storage. - @param context The user-defined context parameter given to the apply - function. -*/ -typedef void (*CFStorageApplierFunction)(const void *val, void *context); - -/*! - @typedef CFStorageRangeApplierBlock - Type of the callback block used by the apply functions of - CFStorage - @param val A pointer to a range of values, numbering range.length - @param range The range of values. This will always be a subrange of the range - passed to the apply function. Do not try to modify the contents of the vals pointer, because - there is no guarantee it points into the contents of the CFStorage object. - @param stop An "out" parameter that, if set to true from within the block, indicates that the enumeration may stop. - -*/ -#if __BLOCKS__ -typedef void (^CFStorageApplierBlock)(const void *vals, CFRange range, bool *stop); -#endif - -/*! - @function CFStorageGetTypeID - Returns the type identifier of all CFStorage instances. -*/ -CF_EXPORT CFTypeID CFStorageGetTypeID(void); - -/*! - @function CFStorageCreate - Creates a new mutable storage with elements of the given size. - @param alloc The CFAllocator which should be used to allocate - memory for the set and its storage for values. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param valueSizeInBytes The size in bytes of each of the elements - to be stored in the storage. If this value is zero or - negative, the result is undefined. - @result A reference to the new CFStorage instance. -*/ -CF_EXPORT CFStorageRef CFStorageCreate(CFAllocatorRef alloc, CFIndex valueSizeInBytes); - -/*! - @function CFStorageInsertValues - Allocates space for range.length values at location range.location. Use - CFStorageReplaceValues() to set those values. - @param storage The storage to which the values are to be inserted. - If this parameter is not a valid CFStorage, the behavior is undefined. - @param range The range of values within the storage to insert. The - range location must be at least zero and not exceed the count of the storage. - Values at indexes equal to or greater than the range location have their indexes - increased by the length of the range. Thus this creates a gap in the storage - equal to the length of the given range. If the range length is negative, the - behavior is undefined. The range may be empty (length 0), - in which case there is no effect. - -*/ -CF_EXPORT void CFStorageInsertValues(CFStorageRef storage, CFRange range); - -/*! - @function CFStorageDeleteValues - Deletes the values of the storage in the specified range. - @param storage The storage from which the values are to be deleted. - If this parameter is not a valid CFStorage, the behavior is undefined. - @param range The range of values within the storage to delete. If the - range location or end point (defined by the location plus - length minus 1) are outside the index space of the storage (0 - to N inclusive, where N is the count of the storage), the - behavior is undefined. If the range length is negative, the - behavior is undefined. The range may be empty (length 0), - in which case no values are deleted. -*/ -CF_EXPORT void CFStorageDeleteValues(CFStorageRef storage, CFRange range); - -/*! - @function CFStorageGetCount - Returns the number of values currently in the storage. - @param storage The storage to be queried. If this parameter is not a valid - CFStorage, the behavior is undefined. - @result The number of values in the storage. -*/ -CF_EXPORT CFIndex CFStorageGetCount(CFStorageRef storage); - -/*! - @function CFStorageGetValueAtIndex - Returns a pointer to the specified value. The pointer is mutable and may be used to - get or set the value. This is considered to be a mutating function, and so calling this - while accessing the CFStorage from another thread is undefined behavior, - even if you do not set a value. To access the CFStorage in a non-mutating - manner, use the more efficient CFStorageGetConstValueAtIndex(). - @param storage The storage to be queried. If this parameter is not a - valid CFStorage, the behavior is undefined. - @param idx The index of the value to retrieve. If the index is - outside the index space of the storage (0 to N-1 inclusive, - where N is the count of the storage), the behavior is - undefined. - @param validConsecutiveValueRange This parameter is a C pointer to a CFRange. - If NULL is specified, this argument is ignored; otherwise, the range - is set to the range of values that may be accessed via an offset from the result pointer. - The range location is set to the index of the lowest consecutive - value and the range length is set to the count of consecutive values. - @result The value with the given index in the storage. -*/ -CF_EXPORT void *CFStorageGetValueAtIndex(CFStorageRef storage, CFIndex idx, CFRange *validConsecutiveValueRange); - -/*! - @function CFStorageGetConstValueAtIndex - Returns a pointer to the specified value. The pointer is immutable and may - only be used to get the value. This is not considered to be a mutating function, - so it is safe to call this concurrently with other non-mutating functions. Furthermore, - this is often more efficient than CFStorageGetValueAtIndex(), so it should be used - in preference to that function when possible. - @param storage The storage to be queried. If this parameter is not a - valid CFStorage, the behavior is undefined. - @param idx The index of the value to retrieve. If the index is - outside the index space of the storage (0 to N-1 inclusive, - where N is the count of the storage), the behavior is - undefined. - @param validConsecutiveValueRange This parameter is a C pointer to a CFRange. - If NULL is specified, this argument is ignored; otherwise, the range - is set to the range of values that may be accessed via an offset from the result pointer. - The range location is set to the index of the lowest consecutive - value and the range length is set to the count of consecutive values. - @result The value with the given index in the storage. -*/ -CF_EXPORT const void *CFStorageGetConstValueAtIndex(CFStorageRef storage, CFIndex idx, CFRange *validConsecutiveValueRange); - -/*! - @function CFStorageGetValues - Fills the buffer with values from the storage. - @param storage The storage to be queried. If this parameter is not a - valid CFStorage, the behavior is undefined. - @param range The range of values within the storage to retrieve. If - the range location or end point (defined by the location - plus length minus 1) are outside the index space of the - storage (0 to N-1 inclusive, where N is the count of the - storage), the behavior is undefined. If the range length is - negative, the behavior is undefined. The range may be empty - (length 0), in which case no values are put into the buffer. - @param values A C array of to be filled with values from the storage. - The values in the C array are ordered - in the same order in which they appear in the storage. If this - parameter is not a valid pointer to a C array of at least - range.length pointers, the behavior is undefined. -*/ -CF_EXPORT void CFStorageGetValues(CFStorageRef storage, CFRange range, void *values); - -/*! - @function CFStorageApplyFunction - Calls a function once for each value in the set. - @param storage The storage to be operated upon. If this parameter is not - a valid CFStorage, the behavior is undefined. - @param range The range of values within the storage to operate on. If the - range location or end point (defined by the location plus - length minus 1) are outside the index space of the storage (0 - to N inclusive, where N is the count of the storage), the - behavior is undefined. If the range length is negative, the - behavior is undefined. The range may be empty (length 0), - in which case the no values are operated on. - @param applier The callback function to call once for each value in - the given storage. If this parameter is not a - pointer to a function of the correct prototype, the behavior - is undefined. If there are values in the storage which the - applier function does not expect or cannot properly apply - to, the behavior is undefined. - @param context A pointer-sized user-defined value, which is passed - as the second parameter to the applier function, but is - otherwise unused by this function. If the context is not - what is expected by the applier function, the behavior is - undefined. -*/ -CF_EXPORT void CFStorageApplyFunction(CFStorageRef storage, CFRange range, CFStorageApplierFunction applier, void *context); - -/*! - @function CFStorageApplyBlock - Enumerates ranges of stored objects with a block. - @param storage The storage to be operated upon. If this parameter is not - a valid CFStorage, the behavior is undefined. - @param range The range of values within the storage to operate on. If the - sum of the range location and length is larger than the - count of the storage, the behavior is undefined. If the - range location or length is negative, the behavior is undefined. - @param options Options controlling how the enumeration may proceed. - @param applier The callback block. The block is passed a pointer to - a buffer of contiguous objects in the storage, and the range of stored - values represented by the buffer. If the block modifies the - contents of the buffer, the behavior is undefined. If the block modifies - the contents of the CFStorage, the behavior is undefined. - - */ -#if __BLOCKS__ -CF_EXPORT void CFStorageApplyBlock(CFStorageRef storage, CFRange range, CFStorageEnumerationOptionFlags options, CFStorageApplierBlock applier); -#endif - - -/*! - @function CFStorageCreateWithSubrange - Returns a new CFStorage that contains a portion of an existing CFStorage. - @param storage The storage to be operated upon. If this parameter is not - a valid CFStorage, the behavior is undefined. - @param range The range of values within the storage to operate on. If the - sum of the range location and length is larger than the - count of the storage, the behavior is undefined. If the - range location or length is negative, the behavior is undefined. - @result A reference to a new CFStorage containing a byte-for-byte copy of - the objects in the range. This may use copy-on-write techniques - to allow efficient implementation. - */ -CF_EXPORT CFStorageRef CFStorageCreateWithSubrange(CFStorageRef storage, CFRange range); - -/*! - @function CFStorageReplaceValues - Replaces a range of values in the storage. - @param storage The storage from which the specified values are to be - removed. If this parameter is not a valid CFStorage, - the behavior is undefined. - @param range The range of values within the storage to replace. If the - range location or end point (defined by the location plus - length minus 1) are outside the index space of the storage (0 - to N inclusive, where N is the count of the storage), the - behavior is undefined. If the range length is negative, the - behavior is undefined. The range may be empty (length 0), - in which case the new values are merely inserted at the - range location. - @param values A C array of the values to be copied into the storage. - The new values in the storage are ordered in the same order - in which they appear in this C array. This parameter may be NULL - if the range length is 0. This C array is not changed or freed by - this function. If this parameter is not a valid pointer to a C array of at least - range length pointers, the behavior is undefined. -*/ -CF_EXPORT void CFStorageReplaceValues(CFStorageRef storage, CFRange range, const void *values); - -/* Private stuff... -*/ -CF_EXPORT CFIndex __CFStorageGetCapacity(CFStorageRef storage); -CF_EXPORT CFIndex __CFStorageGetValueSize(CFStorageRef storage); -CF_EXPORT void __CFStorageSetAlwaysFrozen(CFStorageRef storage, bool alwaysFrozen); - - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFSTORAGE__ */ - diff --git a/CFStorage.h b/CFStorage.h new file mode 120000 index 0000000..d878f0c --- /dev/null +++ b/CFStorage.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStorage.h \ No newline at end of file diff --git a/CFStream.h b/CFStream.h deleted file mode 100644 index 16a37f2..0000000 --- a/CFStream.h +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFStream.h - Copyright (c) 2000-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSTREAM__) -#define __COREFOUNDATION_CFSTREAM__ 1 - -#include -#include -#include -#include -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef CF_ENUM(CFIndex, CFStreamStatus) { - kCFStreamStatusNotOpen = 0, - kCFStreamStatusOpening, /* open is in-progress */ - kCFStreamStatusOpen, - kCFStreamStatusReading, - kCFStreamStatusWriting, - kCFStreamStatusAtEnd, /* no further bytes can be read/written */ - kCFStreamStatusClosed, - kCFStreamStatusError -}; - -typedef CF_OPTIONS(CFOptionFlags, CFStreamEventType) { - kCFStreamEventNone = 0, - kCFStreamEventOpenCompleted = 1, - kCFStreamEventHasBytesAvailable = 2, - kCFStreamEventCanAcceptBytes = 4, - kCFStreamEventErrorOccurred = 8, - kCFStreamEventEndEncountered = 16 -}; - -typedef struct { - CFIndex version; - void *info; - void *(*retain)(void *info); - void (*release)(void *info); - CFStringRef (*copyDescription)(void *info); -} CFStreamClientContext; - -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSInputStream) __CFReadStream * CFReadStreamRef; -typedef struct CF_BRIDGED_MUTABLE_TYPE(NSOutputStream) __CFWriteStream * CFWriteStreamRef; - -typedef void (*CFReadStreamClientCallBack)(CFReadStreamRef stream, CFStreamEventType type, void *clientCallBackInfo); -typedef void (*CFWriteStreamClientCallBack)(CFWriteStreamRef stream, CFStreamEventType type, void *clientCallBackInfo); - -CF_EXPORT -CFTypeID CFReadStreamGetTypeID(void); -CF_EXPORT -CFTypeID CFWriteStreamGetTypeID(void); - -/* Memory streams */ - -/* Value will be a CFData containing all bytes thusfar written; used to recover the data written to a memory write stream. */ -CF_EXPORT -const CFStringRef kCFStreamPropertyDataWritten; - -/* Pass kCFAllocatorNull for bytesDeallocator to prevent CFReadStream from deallocating bytes; otherwise, CFReadStream will deallocate bytes when the stream is destroyed */ -CF_EXPORT -CFReadStreamRef CFReadStreamCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex length, CFAllocatorRef bytesDeallocator); - -/* The stream writes into the buffer given; when bufferCapacity is exhausted, the stream is exhausted (status becomes kCFStreamStatusAtEnd) */ -CF_EXPORT -CFWriteStreamRef CFWriteStreamCreateWithBuffer(CFAllocatorRef alloc, UInt8 *buffer, CFIndex bufferCapacity); - -/* New buffers are allocated from bufferAllocator as bytes are written to the stream. At any point, you can recover the bytes thusfar written by asking for the property kCFStreamPropertyDataWritten, above */ -CF_EXPORT -CFWriteStreamRef CFWriteStreamCreateWithAllocatedBuffers(CFAllocatorRef alloc, CFAllocatorRef bufferAllocator); - -/* File streams */ -CF_EXPORT -CFReadStreamRef CFReadStreamCreateWithFile(CFAllocatorRef alloc, CFURLRef fileURL); -CF_EXPORT -CFWriteStreamRef CFWriteStreamCreateWithFile(CFAllocatorRef alloc, CFURLRef fileURL); -CF_IMPLICIT_BRIDGING_DISABLED -CF_EXPORT -void CFStreamCreateBoundPair(CFAllocatorRef alloc, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream, CFIndex transferBufferSize); -CF_IMPLICIT_BRIDGING_ENABLED - -/* Property for file write streams; value should be a CFBoolean. Set to TRUE to append to a file, rather than to replace its contents */ -CF_EXPORT -const CFStringRef kCFStreamPropertyAppendToFile; - -CF_EXPORT -const CFStringRef kCFStreamPropertyFileCurrentOffset; // Value is a CFNumber - - -/* Socket stream properties */ - -/* Value will be a CFData containing the native handle */ -CF_EXPORT -const CFStringRef kCFStreamPropertySocketNativeHandle; - -/* Value will be a CFString, or NULL if unknown */ -CF_EXPORT -const CFStringRef kCFStreamPropertySocketRemoteHostName; - -/* Value will be a CFNumber, or NULL if unknown */ -CF_EXPORT -const CFStringRef kCFStreamPropertySocketRemotePortNumber; - -CF_IMPLICIT_BRIDGING_DISABLED -/* Socket streams; the returned streams are paired such that they use the same socket; pass NULL if you want only the read stream or the write stream */ -CF_EXPORT -void CFStreamCreatePairWithSocket(CFAllocatorRef alloc, CFSocketNativeHandle sock, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream); -CF_EXPORT -void CFStreamCreatePairWithSocketToHost(CFAllocatorRef alloc, CFStringRef host, UInt32 port, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream); -CF_EXPORT -void CFStreamCreatePairWithPeerSocketSignature(CFAllocatorRef alloc, const CFSocketSignature *signature, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream); -CF_IMPLICIT_BRIDGING_ENABLED - - -/* Returns the current state of the stream */ -CF_EXPORT -CFStreamStatus CFReadStreamGetStatus(CFReadStreamRef stream); -CF_EXPORT -CFStreamStatus CFWriteStreamGetStatus(CFWriteStreamRef stream); - -/* Returns NULL if no error has occurred; otherwise returns the error. */ -CF_EXPORT -CFErrorRef CFReadStreamCopyError(CFReadStreamRef stream) CF_AVAILABLE(10_5, 2_0); -CF_EXPORT -CFErrorRef CFWriteStreamCopyError(CFWriteStreamRef stream) CF_AVAILABLE(10_5, 2_0); - -/* Returns success/failure. Opening a stream causes it to reserve all the system - resources it requires. If the stream can open non-blocking, this will always - return TRUE; listen to the run loop source to find out when the open completes - and whether it was successful, or poll using CFRead/WriteStreamGetStatus(), waiting - for a status of kCFStreamStatusOpen or kCFStreamStatusError. */ -CF_EXPORT -Boolean CFReadStreamOpen(CFReadStreamRef stream); -CF_EXPORT -Boolean CFWriteStreamOpen(CFWriteStreamRef stream); - -/* Terminates the flow of bytes; releases any system resources required by the - stream. The stream may not fail to close. You may call CFStreamClose() to - effectively abort a stream. */ -CF_EXPORT -void CFReadStreamClose(CFReadStreamRef stream); -CF_EXPORT -void CFWriteStreamClose(CFWriteStreamRef stream); - -/* Whether there is data currently available for reading; returns TRUE if it's - impossible to tell without trying */ -CF_EXPORT -Boolean CFReadStreamHasBytesAvailable(CFReadStreamRef stream); - -/* Returns the number of bytes read, or -1 if an error occurs preventing any - bytes from being read, or 0 if the stream's end was encountered. - It is an error to try and read from a stream that hasn't been opened first. - This call will block until at least one byte is available; it will NOT block - until the entire buffer can be filled. To avoid blocking, either poll using - CFReadStreamHasBytesAvailable() or use the run loop and listen for the - kCFStreamCanRead event for notification of data available. */ -CF_EXPORT -CFIndex CFReadStreamRead(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength); - -/* Returns a pointer to an internal buffer if possible (setting *numBytesRead - to the length of the returned buffer), otherwise returns NULL; guaranteed - to return in O(1). Bytes returned in the buffer are considered read from - the stream; if maxBytesToRead is greater than 0, not more than maxBytesToRead - will be returned. If maxBytesToRead is less than or equal to zero, as many bytes - as are readily available will be returned. The returned buffer is good only - until the next stream operation called on the stream. Caller should neither - change the contents of the returned buffer nor attempt to deallocate the buffer; - it is still owned by the stream. */ -CF_EXPORT -const UInt8 *CFReadStreamGetBuffer(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead); - -/* Whether the stream can currently be written to without blocking; - returns TRUE if it's impossible to tell without trying */ -CF_EXPORT -Boolean CFWriteStreamCanAcceptBytes(CFWriteStreamRef stream); - -/* Returns the number of bytes successfully written, -1 if an error has - occurred, or 0 if the stream has been filled to capacity (for fixed-length - streams). If the stream is not full, this call will block until at least - one byte is written. To avoid blocking, either poll via CFWriteStreamCanAcceptBytes - or use the run loop and listen for the kCFStreamCanWrite event. */ -CF_EXPORT -CFIndex CFWriteStreamWrite(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength); - -/* Particular streams can name properties and assign meanings to them; you - access these properties through the following calls. A property is any interesting - information about the stream other than the data being transmitted itself. - Examples include the headers from an HTTP transmission, or the expected - number of bytes, or permission information, etc. Properties that can be set - configure the behavior of the stream, and may only be settable at particular times - (like before the stream has been opened). See the documentation for particular - properties to determine their get- and set-ability. */ -CF_EXPORT -CFTypeRef CFReadStreamCopyProperty(CFReadStreamRef stream, CFStringRef propertyName); -CF_EXPORT -CFTypeRef CFWriteStreamCopyProperty(CFWriteStreamRef stream, CFStringRef propertyName); - -/* Returns TRUE if the stream recognizes and accepts the given property-value pair; - FALSE otherwise. */ -CF_EXPORT -Boolean CFReadStreamSetProperty(CFReadStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue); -CF_EXPORT -Boolean CFWriteStreamSetProperty(CFWriteStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue); - -/* Asynchronous processing - If you wish to neither poll nor block, you may register - a client to hear about interesting events that occur on a stream. Only one client - per stream is allowed; registering a new client replaces the previous one. - - Once you have set a client, the stream must be scheduled to provide the context in - which the client will be called. Streams may be scheduled on a single dispatch queue - or on one or more run loops. If scheduled on a run loop, it is the caller's responsibility - to ensure that at least one of the scheduled run loops is being run. - - NOTE: Unlike other CoreFoundation APIs, pasing a NULL clientContext here will remove - the client. If you do not care about the client context (i.e. your only concern - is that your callback be called), you should pass in a valid context where every - entry is 0 or NULL. - -*/ - -CF_EXPORT -Boolean CFReadStreamSetClient(CFReadStreamRef stream, CFOptionFlags streamEvents, CFReadStreamClientCallBack clientCB, CFStreamClientContext *clientContext); -CF_EXPORT -Boolean CFWriteStreamSetClient(CFWriteStreamRef stream, CFOptionFlags streamEvents, CFWriteStreamClientCallBack clientCB, CFStreamClientContext *clientContext); - -CF_EXPORT -void CFReadStreamScheduleWithRunLoop(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode); -CF_EXPORT -void CFWriteStreamScheduleWithRunLoop(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode); - -CF_EXPORT -void CFReadStreamUnscheduleFromRunLoop(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode); -CF_EXPORT -void CFWriteStreamUnscheduleFromRunLoop(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode); - -/* - * Specify the dispatch queue upon which the client callbacks will be invoked. - * Passing NULL for the queue will prevent future callbacks from being invoked. - * Specifying a dispatch queue using this API will unschedule the stream from - * any run loops it had previously been scheduled upon - similarly, scheduling - * with a runloop will disassociate the stream from any existing dispatch queue. - */ -CF_EXPORT -void CFReadStreamSetDispatchQueue(CFReadStreamRef stream, dispatch_queue_t q) CF_AVAILABLE(10_9, 7_0); - -CF_EXPORT -void CFWriteStreamSetDispatchQueue(CFWriteStreamRef stream, dispatch_queue_t q) CF_AVAILABLE(10_9, 7_0); - -/* - * Returns the previously set dispatch queue with an incremented retain count. - * Note that the stream's queue may have been set to NULL if the stream was - * scheduled on a runloop subsequent to it having had a dispatch queue set. - */ -CF_EXPORT -dispatch_queue_t CFReadStreamCopyDispatchQueue(CFReadStreamRef stream) CF_AVAILABLE(10_9, 7_0); - -CF_EXPORT -dispatch_queue_t CFWriteStreamCopyDispatchQueue(CFWriteStreamRef stream) CF_AVAILABLE(10_9, 7_0); - -/* The following API is deprecated starting in 10.5; please use CFRead/WriteStreamCopyError(), above, instead */ -typedef CF_ENUM(CFIndex, CFStreamErrorDomain) { - kCFStreamErrorDomainCustom = -1L, /* custom to the kind of stream in question */ - kCFStreamErrorDomainPOSIX = 1, /* POSIX errno; interpret using */ - kCFStreamErrorDomainMacOSStatus /* OSStatus type from Carbon APIs; interpret using */ -}; - -typedef struct { - CFIndex domain; - SInt32 error; -} CFStreamError; -CF_EXPORT -CFStreamError CFReadStreamGetError(CFReadStreamRef stream); -CF_EXPORT -CFStreamError CFWriteStreamGetError(CFWriteStreamRef stream); - - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFSTREAM__ */ diff --git a/CFStream.h b/CFStream.h new file mode 120000 index 0000000..bf302d6 --- /dev/null +++ b/CFStream.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStream.h \ No newline at end of file diff --git a/CFStreamAbstract.h b/CFStreamAbstract.h deleted file mode 100644 index ac26664..0000000 --- a/CFStreamAbstract.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFStreamAbstract.h - Copyright (c) 2000-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSTREAMABSTRACT__) -#define __COREFOUNDATION_CFSTREAMABSTRACT__ 1 - -#include - -CF_EXTERN_C_BEGIN - -/* During a stream's lifetime, the open callback will be called once, followed by any number of openCompleted calls (until openCompleted returns TRUE). Then any number of read/canRead or write/canWrite calls, then a single close call. copyProperty can be called at any time. prepareAsynch will be called exactly once when the stream's client is first configured. - - Expected semantics: - - open reserves any system resources that are needed. The stream may start the process of opening, returning TRUE immediately and setting openComplete to FALSE. When the open completes, _CFStreamSignalEvent should be called passing kCFStreamOpenCompletedEvent. openComplete should be set to TRUE only if the open operation completed in its entirety. - - openCompleted will only be called after open has been called, but before any kCFStreamOpenCompletedEvent has been received. Return TRUE, setting error.code to 0, if the open operation has completed. Return TRUE, setting error to the correct error code and domain if the open operation completed, but failed. Return FALSE if the open operation is still in-progress. If your open ever fails to complete (i.e. sets openComplete to FALSE), you must be implement the openCompleted callback. - - read should read into the given buffer, returning the number of bytes successfully read. read must block until at least one byte is available, but should not block until the entire buffer is filled; zero should only be returned if end-of-stream is encountered. atEOF should be set to true if the EOF is encountered, false otherwise. error.code should be set to zero if no error occurs; otherwise, error should be set to the appropriate values. - - getBuffer is an optimization to return an internal buffer of bytes read from the stream, and may return NULL. getBuffer itself may be NULL if the concrete implementation does not wish to provide an internal buffer. If implemented, it should set numBytesRead to the number of bytes available in the internal buffer (but should not exceed maxBytesToRead) and return a pointer to the base of the bytes. - - canRead will only be called once openCompleted reports that the stream has been successfully opened (or the initial open call succeeded). It should return whether there are bytes that can be read without blocking. - - write should write the bytes in the given buffer to the device, returning the number of bytes successfully written. write must block until at least one byte is written. error.code should be set to zero if no error occurs; otherwise, error should be set to the appropriate values. - - close should close the device, releasing any reserved system resources. close cannot fail (it may be called to abort the stream), and may be called at any time after open has been called. It will only be called once. - - copyProperty should return the value for the given property, or NULL if none exists. Composite streams (streams built on top of other streams) should take care to call CFStreamCopyProperty on the base stream if they do not recognize the property given, to give the underlying stream a chance to respond. - - In all cases, errors returned by reference will be initialized to NULL by the caller, and if they are set to non-NULL, will - be released by the caller -*/ - -typedef struct { - CFIndex version; /* == 2 */ - - void *(*create)(CFReadStreamRef stream, void *info); - void (*finalize)(CFReadStreamRef stream, void *info); - CFStringRef (*copyDescription)(CFReadStreamRef stream, void *info); - - Boolean (*open)(CFReadStreamRef stream, CFErrorRef *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFReadStreamRef stream, CFErrorRef *error, void *info); - CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, Boolean *atEOF, void *info); - const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFErrorRef *error, Boolean *atEOF, void *info); - Boolean (*canRead)(CFReadStreamRef stream, CFErrorRef *error, void *info); - void (*close)(CFReadStreamRef stream, void *info); - - CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info); - Boolean (*setProperty)(CFReadStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); - - void (*requestEvents)(CFReadStreamRef stream, CFOptionFlags streamEvents, void *info); - void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFReadStreamCallBacks; - -typedef struct { - CFIndex version; /* == 2 */ - - void *(*create)(CFWriteStreamRef stream, void *info); - void (*finalize)(CFWriteStreamRef stream, void *info); - CFStringRef (*copyDescription)(CFWriteStreamRef stream, void *info); - - Boolean (*open)(CFWriteStreamRef stream, CFErrorRef *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFWriteStreamRef stream, CFErrorRef *error, void *info); - CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, void *info); - Boolean (*canWrite)(CFWriteStreamRef stream, CFErrorRef *error, void *info); - void (*close)(CFWriteStreamRef stream, void *info); - - CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info); - Boolean (*setProperty)(CFWriteStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); - - void (*requestEvents)(CFWriteStreamRef stream, CFOptionFlags streamEvents, void *info); - void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFWriteStreamCallBacks; - -// Primitive creation mechanisms. -CF_EXPORT -CFReadStreamRef CFReadStreamCreate(CFAllocatorRef alloc, const CFReadStreamCallBacks *callbacks, void *info); -CF_EXPORT -CFWriteStreamRef CFWriteStreamCreate(CFAllocatorRef alloc, const CFWriteStreamCallBacks *callbacks, void *info); - -/* All the functions below can only be called when you are sure the stream in question was created via - CFReadStreamCreate() or CFWriteStreamCreate(), above. They are NOT safe for toll-free bridged objects, - so the caller must be sure the argument passed is not such an object. */ - -// To be called by the concrete stream implementation (the callbacks) when an event occurs. error may be NULL if event != kCFStreamEventErrorOccurred -// error should be a CFErrorRef if the callbacks are version 2 or later; otherwise it should be a (CFStreamError *). -CF_EXPORT -void CFReadStreamSignalEvent(CFReadStreamRef stream, CFStreamEventType event, const void *error); -CF_EXPORT -void CFWriteStreamSignalEvent(CFWriteStreamRef stream, CFStreamEventType event, const void *error); - -// These require that the stream allow the run loop to run once before delivering the event to its client. -// See the comment above CFRead/WriteStreamSignalEvent for interpretation of the error argument. -CF_EXPORT -void _CFReadStreamSignalEventDelayed(CFReadStreamRef stream, CFStreamEventType event, const void *error); -CF_EXPORT -void _CFWriteStreamSignalEventDelayed(CFWriteStreamRef stream, CFStreamEventType event, const void *error); - -CF_EXPORT -void _CFReadStreamClearEvent(CFReadStreamRef stream, CFStreamEventType event); -// Write variant not currently needed -//CF_EXPORT -//void _CFWriteStreamClearEvent(CFWriteStreamRef stream, CFStreamEventType event); - -// Convenience for concrete implementations to extract the info pointer given the stream. -CF_EXPORT -void *CFReadStreamGetInfoPointer(CFReadStreamRef stream); -CF_EXPORT -void *CFWriteStreamGetInfoPointer(CFWriteStreamRef stream); - -// Returns the client info pointer currently set on the stream. These should probably be made public one day. -CF_EXPORT -void *_CFReadStreamGetClient(CFReadStreamRef readStream); -CF_EXPORT -void *_CFWriteStreamGetClient(CFWriteStreamRef writeStream); - -// Returns an array of the runloops and modes on which the stream is currently scheduled -// Note that these are unretained mutable arrays - use the copy variant instead. -CF_EXPORT -CFArrayRef _CFReadStreamGetRunLoopsAndModes(CFReadStreamRef readStream); -CF_EXPORT -CFArrayRef _CFWriteStreamGetRunLoopsAndModes(CFWriteStreamRef writeStream); - -// Returns an array of the runloops and modes on which the stream is currently scheduled -CF_EXPORT -CFArrayRef _CFReadStreamCopyRunLoopsAndModes(CFReadStreamRef readStream); -CF_EXPORT -CFArrayRef _CFWriteStreamCopyRunLoopsAndModes(CFWriteStreamRef writeStream); - -/* Deprecated versions; here for backwards compatibility. */ -typedef struct { - CFIndex version; /* == 1 */ - void *(*create)(CFReadStreamRef stream, void *info); - void (*finalize)(CFReadStreamRef stream, void *info); - CFStringRef (*copyDescription)(CFReadStreamRef stream, void *info); - Boolean (*open)(CFReadStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFReadStreamRef stream, CFStreamError *error, void *info); - CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info); - const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info); - Boolean (*canRead)(CFReadStreamRef stream, void *info); - void (*close)(CFReadStreamRef stream, void *info); - CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info); - Boolean (*setProperty)(CFReadStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); - void (*requestEvents)(CFReadStreamRef stream, CFOptionFlags streamEvents, void *info); - void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFReadStreamCallBacksV1; - -typedef struct { - CFIndex version; /* == 1 */ - void *(*create)(CFWriteStreamRef stream, void *info); - void (*finalize)(CFWriteStreamRef stream, void *info); - CFStringRef (*copyDescription)(CFWriteStreamRef stream, void *info); - Boolean (*open)(CFWriteStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFWriteStreamRef stream, CFStreamError *error, void *info); - CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, void *info); - Boolean (*canWrite)(CFWriteStreamRef stream, void *info); - void (*close)(CFWriteStreamRef stream, void *info); - CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info); - Boolean (*setProperty)(CFWriteStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); - void (*requestEvents)(CFWriteStreamRef stream, CFOptionFlags streamEvents, void *info); - void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFWriteStreamCallBacksV1; - -typedef struct { - CFIndex version; /* == 0 */ - Boolean (*open)(CFReadStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFReadStreamRef stream, CFStreamError *error, void *info); - CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info); - const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info); - Boolean (*canRead)(CFReadStreamRef stream, void *info); - void (*close)(CFReadStreamRef stream, void *info); - CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info); - void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFReadStreamCallBacksV0; - -typedef struct { - CFIndex version; /* == 0 */ - Boolean (*open)(CFWriteStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(CFWriteStreamRef stream, CFStreamError *error, void *info); - CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, void *info); - Boolean (*canWrite)(CFWriteStreamRef stream, void *info); - void (*close)(CFWriteStreamRef stream, void *info); - CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info); - void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -} CFWriteStreamCallBacksV0; - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFSTREAMABSTRACT__ */ diff --git a/CFStreamAbstract.h b/CFStreamAbstract.h new file mode 120000 index 0000000..81488ec --- /dev/null +++ b/CFStreamAbstract.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStreamAbstract.h \ No newline at end of file diff --git a/CFStreamInternal.h b/CFStreamInternal.h deleted file mode 100644 index c35a2de..0000000 --- a/CFStreamInternal.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -#if !defined(__COREFOUNDATION_CFSTREAMINTERNAL__) -#define __COREFOUNDATION_CFSTREAMINTERNAL__ 1 - -#include -#include -#include -#include - -CF_EXTERN_C_BEGIN - - -// Older versions of the callbacks; v0 callbacks match v1 callbacks, except that create, finalize, and copyDescription are missing. -typedef Boolean (*_CFStreamCBOpenV1)(struct _CFStream *stream, CFStreamError *error, Boolean *openComplete, void *info); -typedef Boolean (*_CFStreamCBOpenCompletedV1)(struct _CFStream *stream, CFStreamError *error, void *info); -typedef CFIndex (*_CFStreamCBReadV1)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info); -typedef const UInt8 *(*_CFStreamCBGetBufferV1)(CFReadStreamRef sream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info); -typedef Boolean (*_CFStreamCBCanReadV1)(CFReadStreamRef, void *info); -typedef CFIndex (*_CFStreamCBWriteV1)(CFWriteStreamRef, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, void *info); -typedef Boolean (*_CFStreamCBCanWriteV1)(CFWriteStreamRef, void *info); - -struct _CFStreamCallBacksV1 { - CFIndex version; - void *(*create)(struct _CFStream *stream, void *info); - void (*finalize)(struct _CFStream *stream, void *info); - CFStringRef (*copyDescription)(struct _CFStream *stream, void *info); - - _CFStreamCBOpenV1 open; - _CFStreamCBOpenCompletedV1 openCompleted; - _CFStreamCBReadV1 read; - _CFStreamCBGetBufferV1 getBuffer; - _CFStreamCBCanReadV1 canRead; - _CFStreamCBWriteV1 write; - _CFStreamCBCanWriteV1 canWrite; - void (*close)(struct _CFStream *stream, void *info); - - CFTypeRef (*copyProperty)(struct _CFStream *stream, CFStringRef propertyName, void *info); - Boolean (*setProperty)(struct _CFStream *stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); - void (*requestEvents)(struct _CFStream *stream, CFOptionFlags events, void *info); - void (*schedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -}; - -// These two are defined in CFSocketStream.c because that's where the glue for CFNetwork is. -CF_PRIVATE CFErrorRef _CFErrorFromStreamError(CFAllocatorRef alloc, CFStreamError *err); -CF_PRIVATE CFStreamError _CFStreamErrorFromError(CFErrorRef error); - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFSTREAMINTERNAL__ */ - - diff --git a/CFStreamInternal.h b/CFStreamInternal.h new file mode 120000 index 0000000..d2261de --- /dev/null +++ b/CFStreamInternal.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStreamInternal.h \ No newline at end of file diff --git a/CFStreamPriv.h b/CFStreamPriv.h deleted file mode 100644 index e598443..0000000 --- a/CFStreamPriv.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFStreamPriv.h - Copyright (c) 2000-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSTREAMPRIV__) -#define __COREFOUNDATION_CFSTREAMPRIV__ 1 - -#include -#include -#include - -CF_EXTERN_C_BEGIN - -struct _CFStream; -struct _CFStreamClient { - CFStreamClientContext cbContext; - void (*cb)(struct _CFStream *, CFStreamEventType, void *); - CFOptionFlags when; - CFRunLoopSourceRef rlSource; - CFMutableArrayRef runLoopsAndModes; - CFOptionFlags whatToSignal; -}; - -#define CFStreamCurrentVersion 2 - -// A unified set of callbacks so we can use a single structure for all struct _CFStreams. -struct _CFStreamCallBacks { - CFIndex version; - void *(*create)(struct _CFStream *stream, void *info); - void (*finalize)(struct _CFStream *stream, void *info); - CFStringRef (*copyDescription)(struct _CFStream *stream, void *info); - - Boolean (*open)(struct _CFStream *stream, CFErrorRef *error, Boolean *openComplete, void *info); - Boolean (*openCompleted)(struct _CFStream *stream, CFErrorRef *error, void *info); - CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, Boolean *atEOF, void *info); - const UInt8 *(*getBuffer)(CFReadStreamRef sream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFErrorRef *error, Boolean *atEOF, void *info); - Boolean (*canRead)(CFReadStreamRef, CFErrorRef *error, void *info); - CFIndex (*write)(CFWriteStreamRef, const UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, void *info); - Boolean (*canWrite)(CFWriteStreamRef, CFErrorRef *error, void *info); - void (*close)(struct _CFStream *stream, void *info); - - CFTypeRef (*copyProperty)(struct _CFStream *stream, CFStringRef propertyName, void *info); - Boolean (*setProperty)(struct _CFStream *stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); - void (*requestEvents)(struct _CFStream *stream, CFOptionFlags events, void *info); - void (*schedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); - void (*unschedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); -}; - -struct _CFStream; - -CF_EXPORT void* _CFStreamGetInfoPointer(struct _CFStream* stream); - -// cb version must be > 0 -CF_EXPORT struct _CFStream *_CFStreamCreateWithConstantCallbacks(CFAllocatorRef alloc, void *info, const struct _CFStreamCallBacks *cb, Boolean isReading); - -// Only available for streams created with _CFStreamCreateWithConstantCallbacks, above. cb's version must be 1 -CF_EXPORT void _CFStreamSetInfoPointer(struct _CFStream *stream, void *info, const struct _CFStreamCallBacks *cb); - -/* -** _CFStreamSourceScheduleWithRunLoop -** -** Schedules the given run loop source on the given run loop and mode. It then -** adds the loop and mode pair to the runLoopsAndModes list. The list is -** simply a linear list of a loop reference followed by a mode reference. -** -** source Run loop source to be scheduled -** -** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled -** -** runLoop Run loop on which the source is being scheduled -** -** runLoopMode Run loop mode on which the source is being scheduled -*/ -CF_EXPORT -void _CFStreamSourceScheduleWithRunLoop(CFRunLoopSourceRef source, CFMutableArrayRef runLoopsAndModes, CFRunLoopRef runLoop, CFStringRef runLoopMode); - - -/* -** _CFStreamSourceUnscheduleFromRunLoop -** -** Unschedule the given source from the given run loop and mode. It then will -** guarantee that the source remains scheduled on the list of run loop and mode -** pairs in the runLoopsAndModes list. The list is simply a linear list of a -** loop reference followed by a mode reference. -** -** source Run loop source to be unscheduled -** -** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled -** -** runLoop Run loop from which the source is being unscheduled -** -** runLoopMode Run loop mode from which the source is being unscheduled -*/ -CF_EXPORT -void _CFStreamSourceUnscheduleFromRunLoop(CFRunLoopSourceRef source, CFMutableArrayRef runLoopsAndModes, CFRunLoopRef runLoop, CFStringRef runLoopMode); - - -/* -** _CFStreamSourceScheduleWithAllRunLoops -** -** Schedules the given run loop source on all the run loops and modes in the list. -** The list is simply a linear list of a loop reference followed by a mode reference. -** -** source Run loop source to be unscheduled -** -** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled -*/ -CF_EXPORT -void _CFStreamSourceScheduleWithAllRunLoops(CFRunLoopSourceRef source, CFArrayRef runLoopsAndModes); - - -/* -** _CFStreamSourceUnscheduleFromRunLoop -** -** Unschedule the given source from all the run loops and modes in the list. -** The list is simply a linear list of a loop reference followed by a mode -** reference. -** -** source Run loop source to be unscheduled -** -** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled -*/ -CF_EXPORT -void _CFStreamSourceUncheduleFromAllRunLoops(CFRunLoopSourceRef source, CFArrayRef runLoopsAndModes); - -CF_EXPORT -CFReadStreamRef _CFReadStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd); - -CF_EXPORT -CFWriteStreamRef _CFWriteStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd); - - - -#define SECURITY_NONE (0) -#define SECURITY_SSLv2 (1) -#define SECURITY_SSLv3 (2) -#define SECURITY_SSLv32 (3) -#define SECURITY_TLS (4) - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -// This symbol is exported from CFNetwork (see CFSocketStream.i). Only __MACH__ systems will -// get this symbol from CoreFoundation. -extern const int kCFStreamErrorDomainSSL; -#endif - -/* - * Additional SPI for CFNetwork for select side read buffering - */ -CF_EXPORT -Boolean __CFSocketGetBytesAvailable(CFSocketRef s, CFIndex* ctBytesAvailable); - -CF_EXPORT -CFIndex __CFSocketRead(CFSocketRef s, UInt8* buffer, CFIndex length, int* error); - -/* - * This define can be removed once 6030579 is removed - */ -#define CFNETWORK_6030579 1 - -CF_EXPORT -void __CFSocketSetSocketReadBufferAttrs(CFSocketRef s, CFTimeInterval timeout, CFIndex length); - -CF_EXTERN_C_END - -/* - * for CF{Read/Write}StreamCopyProperty created from a file. The - * result is a CFDataRef containing sizeof(int) bytes in machine byte - * ordering representing the file descriptor of the underlying open - * file. If the underlying file descriptor is not open, the property - * value will be NULL (as opposed to containing ((int) -1)). - */ -CF_EXPORT const CFStringRef _kCFStreamPropertyFileNativeHandle CF_AVAILABLE_IOS(5_0); - -#endif /* ! __COREFOUNDATION_CFSTREAMPRIV__ */ - diff --git a/CFStreamPriv.h b/CFStreamPriv.h new file mode 120000 index 0000000..34eca95 --- /dev/null +++ b/CFStreamPriv.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStreamPriv.h \ No newline at end of file diff --git a/CFString.h b/CFString.h deleted file mode 100644 index 9aaa942..0000000 --- a/CFString.h +++ /dev/null @@ -1,891 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFString.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSTRING__) -#define __COREFOUNDATION_CFSTRING__ 1 - -#include -#include -#include -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -/* -Please note: CFStrings are conceptually an array of Unicode characters. -However, in general, how a CFString stores this array is an implementation -detail. For instance, CFString might choose to use an array of 8-bit characters -to store its contents, or it might use multiple blocks of memory, or whatever. -This is especially true since CFString is toll-free bridged with NSString, enabling -any NSString instance to be used as a CFString. Furthermore, the implementation -may change depending on the default system encoding, the user's language, -or even a release or update of the OS. - -What this means is that you should use the following advanced functions with care: - - CFStringGetPascalStringPtr() - CFStringGetCStringPtr() - CFStringGetCharactersPtr() - -These functions are provided for optimization only. They will either return the desired -pointer quickly, in constant time, or they return NULL. They might choose to return NULL -for many reasons; for instance it's possible that for users running in different -languages these sometimes return NULL; or in a future OS release the first two might -switch to always returning NULL. Never observing NULL returns in your usages of these -functions does not mean they won't ever return NULL. (But note the CFStringGetCharactersPtr() -exception mentioned further below.) - -In your usages of these functions, if you get a NULL return, use the non-Ptr version -of the functions as shown in this example: - - char buffer[BUFSIZE]; - const char *ptr = CFStringGetCStringPtr(str, encoding); - if (ptr == NULL) { - if (CFStringGetCString(str, buffer, BUFSIZE, encoding)) ptr = buffer; - } - -Note that CFStringGetCString() or CFStringGetPascalString() calls might still fail --- but -that will happen in two circumstances only: The conversion from the UniChar contents of CFString -to the specified encoding fails, or the buffer is too small. If they fail, that means -the conversion was not possible. - -If you need a copy of the buffer in the above example, you might consider simply calling -CFStringGetCString() in all cases --- CFStringGetCStringPtr() is simply an optimization. - -In addition, the following functions, which create immutable CFStrings from developer -supplied buffers without copying the buffers, might have to actually copy -under certain circumstances (If they do copy, the buffer will be dealt with by the -"contentsDeallocator" argument.): - - CFStringCreateWithPascalStringNoCopy() - CFStringCreateWithCStringNoCopy() - CFStringCreateWithCharactersNoCopy() - -You should of course never depend on the backing store of these CFStrings being -what you provided, and in other no circumstance should you change the contents -of that buffer (given that would break the invariant about the CFString being immutable). - -Having said all this, there are actually ways to create a CFString where the backing store -is external, and can be manipulated by the developer or CFString itself: - - CFStringCreateMutableWithExternalCharactersNoCopy() - CFStringSetExternalCharactersNoCopy() - -A "contentsAllocator" is used to realloc or free the backing store by CFString. -kCFAllocatorNull can be provided to assure CFString will never realloc or free the buffer. -Developer can call CFStringSetExternalCharactersNoCopy() to update -CFString's idea of what's going on, if the buffer is changed externally. In these -strings, CFStringGetCharactersPtr() is guaranteed to return the external buffer. - -These functions are here to allow wrapping a buffer of UniChar characters in a CFString, -allowing the buffer to passed into CFString functions and also manipulated via CFString -mutation functions. In general, developers should not use this technique for all strings, -as it prevents CFString from using certain optimizations. -*/ - -/* Identifier for character encoding; the values are the same as Text Encoding Converter TextEncoding. -*/ -typedef UInt32 CFStringEncoding; - -/* Platform-independent built-in encodings; always available on all platforms. - Call CFStringGetSystemEncoding() to get the default system encoding. -*/ -#define kCFStringEncodingInvalidId (0xffffffffU) -typedef CF_ENUM(CFStringEncoding, CFStringBuiltInEncodings) { - kCFStringEncodingMacRoman = 0, - kCFStringEncodingWindowsLatin1 = 0x0500, /* ANSI codepage 1252 */ - kCFStringEncodingISOLatin1 = 0x0201, /* ISO 8859-1 */ - kCFStringEncodingNextStepLatin = 0x0B01, /* NextStep encoding*/ - kCFStringEncodingASCII = 0x0600, /* 0..127 (in creating CFString, values greater than 0x7F are treated as corresponding Unicode value) */ - kCFStringEncodingUnicode = 0x0100, /* kTextEncodingUnicodeDefault + kTextEncodingDefaultFormat (aka kUnicode16BitFormat) */ - kCFStringEncodingUTF8 = 0x08000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF8Format */ - kCFStringEncodingNonLossyASCII = 0x0BFF, /* 7bit Unicode variants used by Cocoa & Java */ - - kCFStringEncodingUTF16 = 0x0100, /* kTextEncodingUnicodeDefault + kUnicodeUTF16Format (alias of kCFStringEncodingUnicode) */ - kCFStringEncodingUTF16BE = 0x10000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF16BEFormat */ - kCFStringEncodingUTF16LE = 0x14000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF16LEFormat */ - - kCFStringEncodingUTF32 = 0x0c000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF32Format */ - kCFStringEncodingUTF32BE = 0x18000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF32BEFormat */ - kCFStringEncodingUTF32LE = 0x1c000100 /* kTextEncodingUnicodeDefault + kUnicodeUTF32LEFormat */ -}; - - -/* CFString type ID */ -CF_EXPORT -CFTypeID CFStringGetTypeID(void); - -/* CFSTR() allows creation of compile-time constant CFStringRefs; the argument -should be a constant C-string. - -CFSTR(), not being a "Copy" or "Create" function, does not return a new -reference for you. So, you should not release the return value. This is -much like constant C or Pascal strings --- when you use "hello world" -in a program, you do not free it. - -However, strings returned from CFSTR() can be retained and released in a -properly nested fashion, just like any other CF type. That is, if you pass -a CFSTR() return value to a function such as SetMenuItemWithCFString(), the -function can retain it, then later, when it's done with it, it can release it. - -Non-7 bit characters (that is, above 127) in CFSTR() are supported, although care must -be taken in dealing with files containing them. If you can trust your editor and tools -to deal with non-ASCII characters in the source code, then you can use them directly -in CFSTR(); otherwise, you can represent such characters with their escaped octal -equivalents in the encoding the compiler will use to interpret them (for instance, -O-umlaut is \303\226 in UTF-8). UTF-8 is the recommended encoding here, -since it is the default choice with Mac OS X developer tools. -*/ -#if TARGET_OS_WIN32 || TARGET_OS_LINUX -#undef __CONSTANT_CFSTRINGS__ -#endif - -#ifdef __CONSTANT_CFSTRINGS__ -#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr "")) -#else -#define CFSTR(cStr) __CFStringMakeConstantString("" cStr "") -#endif - -#if defined(__GNUC__) && (__GNUC__*10+__GNUC_MINOR__ >= 42) && defined(__APPLE_CC__) && (__APPLE_CC__ > 1) && !defined(__INTEL_COMPILER) && (TARGET_OS_MAC || TARGET_OS_EMBEDDED) -#define CF_FORMAT_FUNCTION(F,A) __attribute__((format(CFString, F, A))) -#define CF_FORMAT_ARGUMENT(A) __attribute__((format_arg(A))) -#else -#define CF_FORMAT_FUNCTION(F,A) -#define CF_FORMAT_ARGUMENT(A) -#endif - -/*** Immutable string creation functions ***/ - -/* Functions to create basic immutable strings. The provided allocator is used for all memory activity in these functions. -*/ - -/* The following four functions copy the provided buffer into CFString's internal storage. */ -CF_EXPORT -CFStringRef CFStringCreateWithPascalString(CFAllocatorRef alloc, ConstStr255Param pStr, CFStringEncoding encoding); - -CF_EXPORT -CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding); - -/* The following takes an explicit length, and allows you to specify whether the data is an external format --- that is, whether to pay attention to the BOM character (if any) and do byte swapping if necessary -*/ -CF_EXPORT -CFStringRef CFStringCreateWithBytes(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalRepresentation); - -CF_EXPORT -CFStringRef CFStringCreateWithCharacters(CFAllocatorRef alloc, const UniChar *chars, CFIndex numChars); - - -/* These functions try not to copy the provided buffer. The buffer will be deallocated -with the provided contentsDeallocator when it's no longer needed; to not free -the buffer, specify kCFAllocatorNull here. As usual, NULL means default allocator. - -NOTE: Do not count on these buffers as being used by the string; -in some cases the CFString might free the buffer and use something else -(for instance if it decides to always use Unicode encoding internally). - -NOTE: If you are not transferring ownership of the buffer to the CFString -(for instance, you supplied contentsDeallocator = kCFAllocatorNull), it is your -responsibility to assure the buffer does not go away during the lifetime of the string. -If the string is retained or copied, its lifetime might extend in ways you cannot -predict. So, for strings created with buffers whose lifetimes you cannot -guarantee, you need to be extremely careful --- do not hand it out to any -APIs which might retain or copy the strings. -*/ -CF_EXPORT -CFStringRef CFStringCreateWithPascalStringNoCopy(CFAllocatorRef alloc, ConstStr255Param pStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator); - -CF_EXPORT -CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator); - -/* The following takes an explicit length, and allows you to specify whether the data is an external format --- that is, whether to pay attention to the BOM character (if any) and do byte swapping if necessary -*/ -CF_EXPORT -CFStringRef CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalRepresentation, CFAllocatorRef contentsDeallocator); - -CF_EXPORT -CFStringRef CFStringCreateWithCharactersNoCopy(CFAllocatorRef alloc, const UniChar *chars, CFIndex numChars, CFAllocatorRef contentsDeallocator); - -/* Create copies of part or all of the string. -*/ -CF_EXPORT -CFStringRef CFStringCreateWithSubstring(CFAllocatorRef alloc, CFStringRef str, CFRange range); - -CF_EXPORT -CFStringRef CFStringCreateCopy(CFAllocatorRef alloc, CFStringRef theString); - -/* These functions create a CFString from the provided printf-like format string and arguments. -*/ -CF_EXPORT -CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...) CF_FORMAT_FUNCTION(3,4); - -CF_EXPORT -CFStringRef CFStringCreateWithFormatAndArguments(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments) CF_FORMAT_FUNCTION(3,0); - -/* Functions to create mutable strings. "maxLength", if not 0, is a hard bound on the length of the string. If 0, there is no limit on the length. -*/ -CF_EXPORT -CFMutableStringRef CFStringCreateMutable(CFAllocatorRef alloc, CFIndex maxLength); - -CF_EXPORT -CFMutableStringRef CFStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFStringRef theString); - -/* This function creates a mutable string that has a developer supplied and directly editable backing store. -The string will be manipulated within the provided buffer (if any) until it outgrows capacity; then the -externalCharactersAllocator will be consulted for more memory. When the CFString is deallocated, the -buffer will be freed with the externalCharactersAllocator. Provide kCFAllocatorNull here to prevent the buffer -from ever being reallocated or deallocated by CFString. See comments at top of this file for more info. -*/ -CF_EXPORT -CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy(CFAllocatorRef alloc, UniChar *chars, CFIndex numChars, CFIndex capacity, CFAllocatorRef externalCharactersAllocator); - -/*** Basic accessors for the contents ***/ - -/* Number of 16-bit Unicode characters in the string. -*/ -CF_EXPORT -CFIndex CFStringGetLength(CFStringRef theString); - -/* Extracting the contents of the string. For obtaining multiple characters, calling -CFStringGetCharacters() is more efficient than multiple calls to CFStringGetCharacterAtIndex(). -If the length of the string is not known (so you can't use a fixed size buffer for CFStringGetCharacters()), -another method is to use is CFStringGetCharacterFromInlineBuffer() (see further below). -*/ -CF_EXPORT -UniChar CFStringGetCharacterAtIndex(CFStringRef theString, CFIndex idx); - -CF_EXPORT -void CFStringGetCharacters(CFStringRef theString, CFRange range, UniChar *buffer); - - -/*** Conversion to other encodings ***/ - -/* These two convert into the provided buffer; they return false if conversion isn't possible -(due to conversion error, or not enough space in the provided buffer). -These functions do zero-terminate or put the length byte; the provided bufferSize should include -space for this (so pass 256 for Str255). More sophisticated usages can go through CFStringGetBytes(). -These functions are equivalent to calling CFStringGetBytes() with -the range of the string; lossByte = 0; and isExternalRepresentation = false; -if successful, they then insert the leading length or terminating zero, as desired. -*/ -CF_EXPORT -Boolean CFStringGetPascalString(CFStringRef theString, StringPtr buffer, CFIndex bufferSize, CFStringEncoding encoding); - -CF_EXPORT -Boolean CFStringGetCString(CFStringRef theString, char *buffer, CFIndex bufferSize, CFStringEncoding encoding); - -/* These functions attempt to return in O(1) time the desired format for the string. -Note that although this means a pointer to the internal structure is being returned, -this can't always be counted on. Please see note at the top of the file for more -details. -*/ -CF_EXPORT -ConstStringPtr CFStringGetPascalStringPtr(CFStringRef theString, CFStringEncoding encoding); /* May return NULL at any time; be prepared for NULL */ - -CF_EXPORT -const char *CFStringGetCStringPtr(CFStringRef theString, CFStringEncoding encoding); /* May return NULL at any time; be prepared for NULL */ - -CF_EXPORT -const UniChar *CFStringGetCharactersPtr(CFStringRef theString); /* May return NULL at any time; be prepared for NULL */ - -/* The primitive conversion routine; allows you to convert a string piece at a time - into a fixed size buffer. Returns number of characters converted. - Characters that cannot be converted to the specified encoding are represented - with the byte specified by lossByte; if lossByte is 0, then lossy conversion - is not allowed and conversion stops, returning partial results. - Pass buffer==NULL if you don't care about the converted string (but just the convertability, - or number of bytes required). - maxBufLength indicates the maximum number of bytes to generate. It is ignored when buffer==NULL. - Does not zero-terminate. If you want to create Pascal or C string, allow one extra byte at start or end. - Setting isExternalRepresentation causes any extra bytes that would allow - the data to be made persistent to be included; for instance, the Unicode BOM. Note that - CFString prepends UTF encoded data with the Unicode BOM - when generating external representation if the target encoding allows. It's important to note that - only UTF-8, UTF-16, and UTF-32 define the handling of the byte order mark character, and the "LE" - and "BE" variants of UTF-16 and UTF-32 don't. -*/ -CF_EXPORT -CFIndex CFStringGetBytes(CFStringRef theString, CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, UInt8 *buffer, CFIndex maxBufLen, CFIndex *usedBufLen); - -/* Convenience functions String <-> Data. These generate "external" formats, that is, formats that - can be written out to disk. For instance, if the encoding is Unicode, - CFStringCreateFromExternalRepresentation() pays attention to the BOM character (if any) - and does byte swapping if necessary. Similarly CFStringCreateExternalRepresentation() will - include a BOM character if appropriate. See CFStringGetBytes() for more on this and lossByte. -*/ -CF_EXPORT -CFStringRef CFStringCreateFromExternalRepresentation(CFAllocatorRef alloc, CFDataRef data, CFStringEncoding encoding); /* May return NULL on conversion error */ - -CF_EXPORT -CFDataRef CFStringCreateExternalRepresentation(CFAllocatorRef alloc, CFStringRef theString, CFStringEncoding encoding, UInt8 lossByte); /* May return NULL on conversion error */ - -/* Hints about the contents of a string -*/ -CF_EXPORT -CFStringEncoding CFStringGetSmallestEncoding(CFStringRef theString); /* Result in O(n) time max */ - -CF_EXPORT -CFStringEncoding CFStringGetFastestEncoding(CFStringRef theString); /* Result in O(1) time max */ - -/* General encoding info -*/ -CF_EXPORT -CFStringEncoding CFStringGetSystemEncoding(void); /* The default encoding for the system; untagged 8-bit characters are usually in this encoding */ - -CF_EXPORT -CFIndex CFStringGetMaximumSizeForEncoding(CFIndex length, CFStringEncoding encoding); /* Max bytes a string of specified length (in UniChars) will take up if encoded */ - - -/*** FileSystem path conversion functions ***/ - -/* Extract the contents of the string as a NULL-terminated 8-bit string appropriate for passing to POSIX APIs (for example, normalized for HFS+). The string is zero-terminated. false will be returned if the conversion results don't fit into the buffer. Use CFStringGetMaximumSizeOfFileSystemRepresentation() if you want to make sure the buffer is of sufficient length. -*/ -CF_EXPORT -Boolean CFStringGetFileSystemRepresentation(CFStringRef string, char *buffer, CFIndex maxBufLen); - -/* Get the upper bound on the number of bytes required to hold the file system representation for the string. This result is returned quickly as a very rough approximation, and could be much larger than the actual space required. The result includes space for the zero termination. If you are allocating a buffer for long-term keeping, it's recommended that you reallocate it smaller (to be the right size) after calling CFStringGetFileSystemRepresentation(). -*/ -CF_EXPORT -CFIndex CFStringGetMaximumSizeOfFileSystemRepresentation(CFStringRef string); - -/* Create a CFString from the specified zero-terminated POSIX file system representation. If the conversion fails (possible due to bytes in the buffer not being a valid sequence of bytes for the appropriate character encoding), NULL is returned. -*/ -CF_EXPORT -CFStringRef CFStringCreateWithFileSystemRepresentation(CFAllocatorRef alloc, const char *buffer); - - -/*** Comparison functions. ***/ - -/* Find and compare flags; these are OR'ed together and provided as CFStringCompareFlags in the various functions. -*/ -typedef CF_OPTIONS(CFOptionFlags, CFStringCompareFlags) { - kCFCompareCaseInsensitive = 1, - kCFCompareBackwards = 4, /* Starting from the end of the string */ - kCFCompareAnchored = 8, /* Only at the specified starting point */ - kCFCompareNonliteral = 16, /* If specified, loose equivalence is performed (o-umlaut == o, umlaut) */ - kCFCompareLocalized = 32, /* User's default locale is used for the comparisons */ - kCFCompareNumerically = 64, /* Numeric comparison is used; that is, Foo2.txt < Foo7.txt < Foo25.txt */ - kCFCompareDiacriticInsensitive CF_ENUM_AVAILABLE(10_5, 2_0) = 128, /* If specified, ignores diacritics (o-umlaut == o) */ - kCFCompareWidthInsensitive CF_ENUM_AVAILABLE(10_5, 2_0) = 256, /* If specified, ignores width differences ('a' == UFF41) */ - kCFCompareForcedOrdering CF_ENUM_AVAILABLE(10_5, 2_0) = 512 /* If specified, comparisons are forced to return either kCFCompareLessThan or kCFCompareGreaterThan if the strings are equivalent but not strictly equal, for stability when sorting (e.g. "aaa" > "AAA" with kCFCompareCaseInsensitive specified) */ -}; - -/* The main comparison routine; compares specified range of the first string to (the full range of) the second string. - locale == NULL indicates canonical locale (the return value from CFLocaleGetSystem()). - kCFCompareNumerically, added in 10.2, does not work if kCFCompareLocalized is specified on systems before 10.3 - kCFCompareBackwards and kCFCompareAnchored are not applicable. - rangeToCompare applies to the first string; that is, only the substring of theString1 specified by rangeToCompare is compared against all of theString2. -*/ -CF_EXPORT -CFComparisonResult CFStringCompareWithOptionsAndLocale(CFStringRef theString1, CFStringRef theString2, CFRange rangeToCompare, CFStringCompareFlags compareOptions, CFLocaleRef locale) CF_AVAILABLE(10_5, 2_0); - -/* Comparison convenience. Uses the current user locale (the return value from CFLocaleCopyCurrent()) if kCFCompareLocalized. Refer to CFStringCompareWithOptionsAndLocale() for more info. -*/ -CF_EXPORT -CFComparisonResult CFStringCompareWithOptions(CFStringRef theString1, CFStringRef theString2, CFRange rangeToCompare, CFStringCompareFlags compareOptions); - -/* Comparison convenience suitable for passing as sorting functions. - kCFCompareNumerically, added in 10.2, does not work if kCFCompareLocalized is specified on systems before 10.3 - kCFCompareBackwards and kCFCompareAnchored are not applicable. -*/ -CF_EXPORT -CFComparisonResult CFStringCompare(CFStringRef theString1, CFStringRef theString2, CFStringCompareFlags compareOptions); - -/* CFStringFindWithOptionsAndLocale() returns the found range in the CFRange * argument; you can pass NULL for simple discovery check. - locale == NULL indicates canonical locale (the return value from CFLocaleGetSystem()). - If stringToFind is the empty string (zero length), nothing is found. - Ignores the kCFCompareNumerically option. - Only the substring of theString specified by rangeToSearch is searched for stringToFind. -*/ -CF_EXPORT -Boolean CFStringFindWithOptionsAndLocale(CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFStringCompareFlags searchOptions, CFLocaleRef locale, CFRange *result) CF_AVAILABLE(10_5, 2_0); - -/* Find convenience. Uses the current user locale (the return value from CFLocaleCopyCurrent()) if kCFCompareLocalized. Refer to CFStringFindWithOptionsAndLocale() for more info. -*/ -CF_EXPORT -Boolean CFStringFindWithOptions(CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFStringCompareFlags searchOptions, CFRange *result); - -/* CFStringCreateArrayWithFindResults() returns an array of CFRange pointers, or NULL if there are no matches. - Overlapping instances are not found; so looking for "AA" in "AAA" finds just one range. - Post 10.1: If kCFCompareBackwards is provided, the scan is done from the end (which can give a different result), and - the results are stored in the array backwards (last found range in slot 0). - If stringToFind is the empty string (zero length), nothing is found. - kCFCompareAnchored causes just the consecutive instances at start (or end, if kCFCompareBackwards) to be reported. So, searching for "AB" in "ABABXAB..." you just get the first two occurrences. - Ignores the kCFCompareNumerically option. - Only the substring of theString specified by rangeToSearch is searched for stringToFind. -*/ -CF_EXPORT -CFArrayRef CFStringCreateArrayWithFindResults(CFAllocatorRef alloc, CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFStringCompareFlags compareOptions); - -/* Find conveniences; see comments above concerning empty string and options. -*/ -CF_EXPORT -CFRange CFStringFind(CFStringRef theString, CFStringRef stringToFind, CFStringCompareFlags compareOptions); - -CF_EXPORT -Boolean CFStringHasPrefix(CFStringRef theString, CFStringRef prefix); - -CF_EXPORT -Boolean CFStringHasSuffix(CFStringRef theString, CFStringRef suffix); - -/*! - @function CFStringGetRangeOfComposedCharactersAtIndex - Returns the range of the composed character sequence at the specified index. - @param theString The CFString which is to be searched. If this - parameter is not a valid CFString, the behavior is - undefined. - @param theIndex The index of the character contained in the - composed character sequence. If the index is - outside the index space of the string (0 to N-1 inclusive, - where N is the length of the string), the behavior is - undefined. - @result The range of the composed character sequence. -*/ -CF_EXPORT CFRange CFStringGetRangeOfComposedCharactersAtIndex(CFStringRef theString, CFIndex theIndex); - -/*! - @function CFStringFindCharacterFromSet - Query the range of the first character contained in the specified character set. - @param theString The CFString which is to be searched. If this - parameter is not a valid CFString, the behavior is - undefined. - @param theSet The CFCharacterSet against which the membership - of characters is checked. If this parameter is not a valid - CFCharacterSet, the behavior is undefined. - @param range The range of characters within the string to search. If - the range location or end point (defined by the location - plus length minus 1) are outside the index space of the - string (0 to N-1 inclusive, where N is the length of the - string), the behavior is undefined. If the range length is - negative, the behavior is undefined. The range may be empty - (length 0), in which case no search is performed. - @param searchOptions The bitwise-or'ed option flags to control - the search behavior. The supported options are - kCFCompareBackwards andkCFCompareAnchored. - If other option flags are specified, the behavior - is undefined. - @param result The pointer to a CFRange supplied by the caller in - which the search result is stored. Note that the length - of this range can be more than 1, if for instance the - result is a composed character. If a pointer to an invalid - memory is specified, the behavior is undefined. - @result true, if at least a character which is a member of the character - set is found and result is filled, otherwise, false. -*/ -CF_EXPORT Boolean CFStringFindCharacterFromSet(CFStringRef theString, CFCharacterSetRef theSet, CFRange rangeToSearch, CFStringCompareFlags searchOptions, CFRange *result); - -/* Find range of bounds of the line(s) that span the indicated range (startIndex, numChars), - taking into account various possible line separator sequences (CR, CRLF, LF, and Unicode NextLine, LineSeparator, ParagraphSeparator). - All return values are "optional" (provide NULL if you don't want them) - lineBeginIndex: index of first character in line - lineEndIndex: index of first character of the next line (including terminating line separator characters) - contentsEndIndex: index of the first line separator character - Thus, lineEndIndex - lineBeginIndex is the number of chars in the line, including the line separators - contentsEndIndex - lineBeginIndex is the number of chars in the line w/out the line separators -*/ -CF_EXPORT -void CFStringGetLineBounds(CFStringRef theString, CFRange range, CFIndex *lineBeginIndex, CFIndex *lineEndIndex, CFIndex *contentsEndIndex); - -/* Same as CFStringGetLineBounds(), however, will only look for paragraphs. Won't stop at Unicode NextLine or LineSeparator characters. -*/ -CF_EXPORT -void CFStringGetParagraphBounds(CFStringRef string, CFRange range, CFIndex *parBeginIndex, CFIndex *parEndIndex, CFIndex *contentsEndIndex) CF_AVAILABLE(10_5, 2_0); - -/*! - @function CFStringGetHyphenationLocationBeforeIndex - Retrieve the first potential hyphenation location found before the specified location. - @param string The CFString which is to be hyphenated. If this - parameter is not a valid CFString, the behavior is - undefined. - @param location An index in the string. If a valid hyphen index is returned, it - will be before this index. - @param limitRange The range of characters within the string to search. If - the range location or end point (defined by the location - plus length minus 1) are outside the index space of the - string (0 to N-1 inclusive, where N is the length of the - string), the behavior is undefined. If the range length is - negative, the behavior is undefined. The range may be empty - (length 0), in which case no hyphen location is generated. - @param options Reserved for future use. - @param locale Specifies which language's hyphenation conventions to use. - This must be a valid locale. Hyphenation data is not available - for all locales. You can use CFStringIsHyphenationAvailableForLocale - to test for availability of hyphenation data. - @param character The suggested hyphen character to insert. Pass NULL if you - do not need this information. - @result an index in the string where it is appropriate to insert a hyphen, if - one exists; else kCFNotFound -*/ -CF_EXPORT -CFIndex CFStringGetHyphenationLocationBeforeIndex(CFStringRef string, CFIndex location, CFRange limitRange, CFOptionFlags options, CFLocaleRef locale, UTF32Char *character) CF_AVAILABLE(10_7, 4_2); - -CF_EXPORT -Boolean CFStringIsHyphenationAvailableForLocale(CFLocaleRef locale) CF_AVAILABLE(10_7, 4_3); - -/*** Exploding and joining strings with a separator string ***/ - -CF_EXPORT -CFStringRef CFStringCreateByCombiningStrings(CFAllocatorRef alloc, CFArrayRef theArray, CFStringRef separatorString); /* Empty array returns empty string; one element array returns the element */ - -CF_EXPORT -CFArrayRef CFStringCreateArrayBySeparatingStrings(CFAllocatorRef alloc, CFStringRef theString, CFStringRef separatorString); /* No separators in the string returns array with that string; string == sep returns two empty strings */ - - -/*** Parsing non-localized numbers from strings ***/ - -CF_EXPORT -SInt32 CFStringGetIntValue(CFStringRef str); /* Skips whitespace; returns 0 on error, MAX or -MAX on overflow */ - -CF_EXPORT -double CFStringGetDoubleValue(CFStringRef str); /* Skips whitespace; returns 0.0 on error */ - - -/*** MutableString functions ***/ - -/* CFStringAppend("abcdef", "xxxxx") -> "abcdefxxxxx" - CFStringDelete("abcdef", CFRangeMake(2, 3)) -> "abf" - CFStringReplace("abcdef", CFRangeMake(2, 3), "xxxxx") -> "abxxxxxf" - CFStringReplaceAll("abcdef", "xxxxx") -> "xxxxx" -*/ -CF_EXPORT -void CFStringAppend(CFMutableStringRef theString, CFStringRef appendedString); - -CF_EXPORT -void CFStringAppendCharacters(CFMutableStringRef theString, const UniChar *chars, CFIndex numChars); - -CF_EXPORT -void CFStringAppendPascalString(CFMutableStringRef theString, ConstStr255Param pStr, CFStringEncoding encoding); - -CF_EXPORT -void CFStringAppendCString(CFMutableStringRef theString, const char *cStr, CFStringEncoding encoding); - -CF_EXPORT -void CFStringAppendFormat(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, ...) CF_FORMAT_FUNCTION(3,4); - -CF_EXPORT -void CFStringAppendFormatAndArguments(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments) CF_FORMAT_FUNCTION(3,0); - -CF_EXPORT -void CFStringInsert(CFMutableStringRef str, CFIndex idx, CFStringRef insertedStr); - -CF_EXPORT -void CFStringDelete(CFMutableStringRef theString, CFRange range); - -CF_EXPORT -void CFStringReplace(CFMutableStringRef theString, CFRange range, CFStringRef replacement); - -CF_EXPORT -void CFStringReplaceAll(CFMutableStringRef theString, CFStringRef replacement); /* Replaces whole string */ - -/* Replace all occurrences of target in rangeToSearch of theString with replacement. - Pays attention to kCFCompareCaseInsensitive, kCFCompareBackwards, kCFCompareNonliteral, and kCFCompareAnchored. - kCFCompareBackwards can be used to do the replacement starting from the end, which could give a different result. - ex. AAAAA, replace AA with B -> BBA or ABB; latter if kCFCompareBackwards - kCFCompareAnchored assures only anchored but multiple instances are found (the instances must be consecutive at start or end) - ex. AAXAA, replace A with B -> BBXBB or BBXAA; latter if kCFCompareAnchored - Returns number of replacements performed. -*/ -CF_EXPORT -CFIndex CFStringFindAndReplace(CFMutableStringRef theString, CFStringRef stringToFind, CFStringRef replacementString, CFRange rangeToSearch, CFStringCompareFlags compareOptions); - - -/* This function will make the contents of a mutable CFString point directly at the specified UniChar array. - It works only with CFStrings created with CFStringCreateMutableWithExternalCharactersNoCopy(). - This function does not free the previous buffer. - The string will be manipulated within the provided buffer (if any) until it outgrows capacity; then the - externalCharactersAllocator will be consulted for more memory. - See comments at the top of this file for more info. -*/ -CF_EXPORT -void CFStringSetExternalCharactersNoCopy(CFMutableStringRef theString, UniChar *chars, CFIndex length, CFIndex capacity); /* Works only on specially created mutable strings! */ - -/* CFStringPad() will pad or cut down a string to the specified size. - The pad string is used as the fill string; indexIntoPad specifies which character to start with. - CFStringPad("abc", " ", 9, 0) -> "abc " - CFStringPad("abc", ". ", 9, 1) -> "abc . . ." - CFStringPad("abcdef", ?, 3, ?) -> "abc" - - CFStringTrim() will trim the specified string from both ends of the string. - CFStringTrimWhitespace() will do the same with white space characters (tab, newline, etc) - CFStringTrim(" abc ", " ") -> "abc" - CFStringTrim("* * * *abc * ", "* ") -> "*abc " -*/ -CF_EXPORT -void CFStringPad(CFMutableStringRef theString, CFStringRef padString, CFIndex length, CFIndex indexIntoPad); - -CF_EXPORT -void CFStringTrim(CFMutableStringRef theString, CFStringRef trimString); - -CF_EXPORT -void CFStringTrimWhitespace(CFMutableStringRef theString); - -CF_EXPORT -void CFStringLowercase(CFMutableStringRef theString, CFLocaleRef locale); - -CF_EXPORT -void CFStringUppercase(CFMutableStringRef theString, CFLocaleRef locale); - -CF_EXPORT -void CFStringCapitalize(CFMutableStringRef theString, CFLocaleRef locale); - -/*! - @typedef CFStringNormalizationForm - This is the type of Unicode normalization forms as described in - Unicode Technical Report #15. To normalize for use with file - system calls, use CFStringGetFileSystemRepresentation(). -*/ -typedef CF_ENUM(CFIndex, CFStringNormalizationForm) { - kCFStringNormalizationFormD = 0, // Canonical Decomposition - kCFStringNormalizationFormKD, // Compatibility Decomposition - kCFStringNormalizationFormC, // Canonical Decomposition followed by Canonical Composition - kCFStringNormalizationFormKC // Compatibility Decomposition followed by Canonical Composition -}; - -/*! - @function CFStringNormalize - Normalizes the string into the specified form as described in - Unicode Technical Report #15. - @param theString The string which is to be normalized. If this - parameter is not a valid mutable CFString, the behavior is - undefined. - @param theForm The form into which the string is to be normalized. - If this parameter is not a valid CFStringNormalizationForm value, - the behavior is undefined. -*/ -CF_EXPORT void CFStringNormalize(CFMutableStringRef theString, CFStringNormalizationForm theForm); - - -/*! - @function CFStringFold - Folds the string into the form specified by the flags. - Character foldings are operations that convert any of a set of characters - sharing similar semantics into a single representative from that set. - This function can be used to preprocess strings that are to be compared, - searched, or indexed. - Note that folding does not include normalization, so it is necessary - to use CFStringNormalize in addition to CFStringFold in order to obtain - the effect of kCFCompareNonliteral. - @param theString The string which is to be folded. If this parameter is not - a valid mutable CFString, the behavior is undefined. - @param theFlag The equivalency flags which describes the character folding form. - Only those flags containing the word "insensitive" are recognized here; other flags are ignored. - Folding with kCFCompareCaseInsensitive removes case distinctions in accordance with the mapping - specified by ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt. Folding with - kCFCompareDiacriticInsensitive removes distinctions of accents and other diacritics. Folding - with kCFCompareWidthInsensitive removes character width distinctions by mapping characters in - the range U+FF00-U+FFEF to their ordinary equivalents. - @param theLocale The locale tailoring the character folding behavior. If NULL, - it's considered to be the system locale returned from CFLocaleGetSystem(). - If non-NULL and not a valid CFLocale object, the behavior is undefined. -*/ - -CF_EXPORT -void CFStringFold(CFMutableStringRef theString, CFStringCompareFlags theFlags, CFLocaleRef theLocale) CF_AVAILABLE(10_5, 2_0); - -/* Perform string transliteration. The transformation represented by transform is applied to the given range of string, modifying it in place. Only the specified range will be modified, but the transform may look at portions of the string outside that range for context. NULL range pointer causes the whole string to be transformed. On return, range is modified to reflect the new range corresponding to the original range. reverse indicates that the inverse transform should be used instead, if it exists. If the transform is successful, true is returned; if unsuccessful, false. Reasons for the transform being unsuccessful include an invalid transform identifier, or attempting to reverse an irreversible transform. - -You can pass one of the predefined transforms below, or any valid ICU transform ID as defined in the ICU User Guide. Note that we do not support arbitrary set of ICU transform rules. -*/ -CF_EXPORT -Boolean CFStringTransform(CFMutableStringRef string, CFRange *range, CFStringRef transform, Boolean reverse); - -/* Transform identifiers for CFStringTransform() -*/ -CF_EXPORT const CFStringRef kCFStringTransformStripCombiningMarks; -CF_EXPORT const CFStringRef kCFStringTransformToLatin; -CF_EXPORT const CFStringRef kCFStringTransformFullwidthHalfwidth; -CF_EXPORT const CFStringRef kCFStringTransformLatinKatakana; -CF_EXPORT const CFStringRef kCFStringTransformLatinHiragana; -CF_EXPORT const CFStringRef kCFStringTransformHiraganaKatakana; -CF_EXPORT const CFStringRef kCFStringTransformMandarinLatin; -CF_EXPORT const CFStringRef kCFStringTransformLatinHangul; -CF_EXPORT const CFStringRef kCFStringTransformLatinArabic; -CF_EXPORT const CFStringRef kCFStringTransformLatinHebrew; -CF_EXPORT const CFStringRef kCFStringTransformLatinThai; -CF_EXPORT const CFStringRef kCFStringTransformLatinCyrillic; -CF_EXPORT const CFStringRef kCFStringTransformLatinGreek; -CF_EXPORT const CFStringRef kCFStringTransformToXMLHex; -CF_EXPORT const CFStringRef kCFStringTransformToUnicodeName; -CF_EXPORT const CFStringRef kCFStringTransformStripDiacritics CF_AVAILABLE(10_5, 2_0); - - -/*** General encoding related functionality ***/ - -/* This returns availability of the encoding on the system -*/ -CF_EXPORT -Boolean CFStringIsEncodingAvailable(CFStringEncoding encoding); - -/* This function returns list of available encodings. The returned list is terminated with kCFStringEncodingInvalidId and owned by the system. -*/ -CF_EXPORT -const CFStringEncoding *CFStringGetListOfAvailableEncodings(void); - -/* Returns name of the encoding; non-localized. -*/ -CF_EXPORT -CFStringRef CFStringGetNameOfEncoding(CFStringEncoding encoding); - -/* ID mapping functions from/to Cocoa NSStringEncoding. Returns kCFStringEncodingInvalidId if no mapping exists. -*/ -CF_EXPORT -unsigned long CFStringConvertEncodingToNSStringEncoding(CFStringEncoding encoding); - -CF_EXPORT -CFStringEncoding CFStringConvertNSStringEncodingToEncoding(unsigned long encoding); - -/* ID mapping functions from/to Microsoft Windows codepage (covers both OEM & ANSI). Returns kCFStringEncodingInvalidId if no mapping exists. -*/ -CF_EXPORT -UInt32 CFStringConvertEncodingToWindowsCodepage(CFStringEncoding encoding); - -CF_EXPORT -CFStringEncoding CFStringConvertWindowsCodepageToEncoding(UInt32 codepage); - -/* ID mapping functions from/to IANA registery charset names. Returns kCFStringEncodingInvalidId if no mapping exists. -*/ -CF_EXPORT -CFStringEncoding CFStringConvertIANACharSetNameToEncoding(CFStringRef theString); - -CF_EXPORT -CFStringRef CFStringConvertEncodingToIANACharSetName(CFStringEncoding encoding); - -/* Returns the most compatible MacOS script value for the input encoding */ -/* i.e. kCFStringEncodingMacRoman -> kCFStringEncodingMacRoman */ -/* kCFStringEncodingWindowsLatin1 -> kCFStringEncodingMacRoman */ -/* kCFStringEncodingISO_2022_JP -> kCFStringEncodingMacJapanese */ -CF_EXPORT -CFStringEncoding CFStringGetMostCompatibleMacStringEncoding(CFStringEncoding encoding); - - - -/* The next two functions allow fast access to the contents of a string, - assuming you are doing sequential or localized accesses. To use, call - CFStringInitInlineBuffer() with a CFStringInlineBuffer (on the stack, say), - and a range in the string to look at. Then call CFStringGetCharacterFromInlineBuffer() - as many times as you want, with a index into that range (relative to the start - of that range). These are INLINE functions and will end up calling CFString only - once in a while, to fill a buffer. CFStringGetCharacterFromInlineBuffer() returns 0 if - a location outside the original range is specified. -*/ -#define __kCFStringInlineBufferLength 64 -typedef struct { - UniChar buffer[__kCFStringInlineBufferLength]; - CFStringRef theString; - const UniChar *directUniCharBuffer; - const char *directCStringBuffer; - CFRange rangeToBuffer; /* Range in string to buffer */ - CFIndex bufferedRangeStart; /* Start of range currently buffered (relative to rangeToBuffer.location) */ - CFIndex bufferedRangeEnd; /* bufferedRangeStart + number of chars actually buffered */ -} CFStringInlineBuffer; - -#if defined(CF_INLINE) -CF_INLINE void CFStringInitInlineBuffer(CFStringRef str, CFStringInlineBuffer *buf, CFRange range) { - buf->theString = str; - buf->rangeToBuffer = range; - buf->directCStringBuffer = (buf->directUniCharBuffer = CFStringGetCharactersPtr(str)) ? NULL : CFStringGetCStringPtr(str, kCFStringEncodingASCII); - buf->bufferedRangeStart = buf->bufferedRangeEnd = 0; -} - -CF_INLINE UniChar CFStringGetCharacterFromInlineBuffer(CFStringInlineBuffer *buf, CFIndex idx) { - if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0; - if (buf->directUniCharBuffer) return buf->directUniCharBuffer[idx + buf->rangeToBuffer.location]; - if (buf->directCStringBuffer) return (UniChar)(buf->directCStringBuffer[idx + buf->rangeToBuffer.location]); - if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) { - if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0; - buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength; - if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length; - CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer); - } - return buf->buffer[idx - buf->bufferedRangeStart]; -} - -#else -/* If INLINE functions are not available, we do somewhat less powerful macros that work similarly (except be aware that the buf argument is evaluated multiple times). -*/ -#define CFStringInitInlineBuffer(str, buf, range) \ - do {(buf)->theString = str; (buf)->rangeToBuffer = range; (buf)->directCStringBuffer = ((buf)->directUniCharBuffer = CFStringGetCharactersPtr(str)) ? NULL : CFStringGetCStringPtr(str, kCFStringEncodingASCII);} while (0) - -#define CFStringGetCharacterFromInlineBuffer(buf, idx) \ - (((idx) < 0 || (idx) >= (buf)->rangeToBuffer.length) ? 0 : ((buf)->directUniCharBuffer ? (buf)->directUniCharBuffer[(idx) + (buf)->rangeToBuffer.location] : ((buf)->directCStringBuffer ? (UniChar)((buf)->directCStringBuffer[(idx) + (buf)->rangeToBuffer.location]) : CFStringGetCharacterAtIndex((buf)->theString, (idx) + (buf)->rangeToBuffer.location)))) - -#endif /* CF_INLINE */ - - - -/* UTF-16 surrogate support - */ -CF_INLINE Boolean CFStringIsSurrogateHighCharacter(UniChar character) { - return ((character >= 0xD800UL) && (character <= 0xDBFFUL) ? true : false); -} - -CF_INLINE Boolean CFStringIsSurrogateLowCharacter(UniChar character) { - return ((character >= 0xDC00UL) && (character <= 0xDFFFUL) ? true : false); -} - -CF_INLINE UTF32Char CFStringGetLongCharacterForSurrogatePair(UniChar surrogateHigh, UniChar surrogateLow) { - return (UTF32Char)(((surrogateHigh - 0xD800UL) << 10) + (surrogateLow - 0xDC00UL) + 0x0010000UL); -} - -// Maps a UTF-32 character to a pair of UTF-16 surrogate characters. The buffer pointed by surrogates has to have space for at least 2 UTF-16 characters. Returns true if mapped to a surrogate pair. -CF_INLINE Boolean CFStringGetSurrogatePairForLongCharacter(UTF32Char character, UniChar *surrogates) { - if ((character > 0xFFFFUL) && (character < 0x110000UL)) { // Non-BMP character - character -= 0x10000; - if (NULL != surrogates) { - surrogates[0] = (UniChar)((character >> 10) + 0xD800UL); - surrogates[1] = (UniChar)((character & 0x3FF) + 0xDC00UL); - } - return true; - } else { - if (NULL != surrogates) *surrogates = (UniChar)character; - return false; - } -} - -/* Rest of the stuff in this file is private and should not be used directly -*/ -/* For debugging only; output goes to stderr - Use CFShow() to printf the description of any CFType; - Use CFShowStr() to printf detailed info about a CFString -*/ -CF_EXPORT -void CFShow(CFTypeRef obj); - -CF_EXPORT -void CFShowStr(CFStringRef str); - -/* This function is private and should not be used directly */ -CF_EXPORT -CFStringRef __CFStringMakeConstantString(const char *cStr) CF_FORMAT_ARGUMENT(1); /* Private; do not use */ - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFSTRING__ */ diff --git a/CFString.h b/CFString.h new file mode 120000 index 0000000..8c19c2d --- /dev/null +++ b/CFString.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFString.h \ No newline at end of file diff --git a/CFStringDefaultEncoding.h b/CFStringDefaultEncoding.h deleted file mode 100644 index 46f811e..0000000 --- a/CFStringDefaultEncoding.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFStringDefaultEncoding.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSTRINGDEFAULTENCODING__) -#define __COREFOUNDATION_CFSTRINGDEFAULTENCODING__ 1 - -#include - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -#include -#include -#include -#include -#include -#include -#include -#include - -CF_EXTERN_C_BEGIN - -#define __kCFUserEncodingEnvVariableName ("__CF_USER_TEXT_ENCODING") -#define __kCFMaxDefaultEncodingFileLength (64) -#define __kCFUserEncodingFileName ("/.CFUserTextEncoding") - -CF_EXPORT void _CFStringGetUserDefaultEncoding(UInt32 *oScriptValue, UInt32 *oRegionValue); -CF_EXPORT void _CFStringGetInstallationEncodingAndRegion(uint32_t *encoding, uint32_t *region); -CF_EXPORT Boolean _CFStringSaveUserDefaultEncoding(UInt32 iScriptValue, UInt32 iRegionValue); - -CF_INLINE void __CFStringGetUserDefaultEncoding(UInt32 *oScriptValue, UInt32 *oRegionValue) { _CFStringGetUserDefaultEncoding(oScriptValue, oRegionValue); } -CF_INLINE void __CFStringGetInstallationEncodingAndRegion(uint32_t *encoding, uint32_t *region) { _CFStringGetInstallationEncodingAndRegion(encoding, region); } -CF_INLINE void __CFStringSaveUserDefaultEncoding(UInt32 iScriptValue, UInt32 iRegionValue) { _CFStringSaveUserDefaultEncoding(iScriptValue, iRegionValue); } - -CF_EXTERN_C_END - -#endif - -#endif /* ! __COREFOUNDATION_CFSTRINGDEFAULTENCODING__ */ - - diff --git a/CFStringDefaultEncoding.h b/CFStringDefaultEncoding.h new file mode 120000 index 0000000..494c31c --- /dev/null +++ b/CFStringDefaultEncoding.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStringDefaultEncoding.h \ No newline at end of file diff --git a/CFStringEncodingConverter.h b/CFStringEncodingConverter.h deleted file mode 100644 index 0275be0..0000000 --- a/CFStringEncodingConverter.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFStringEncodingConverter.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERTER__) -#define __COREFOUNDATION_CFSTRINGENCODINGCONVERTER__ 1 - -#include - - -CF_EXTERN_C_BEGIN - -/* Values for flags argument for the conversion functions below. These can be combined, but the three NonSpacing behavior flags are exclusive. -*/ -// kCFStringEncodingBasicDirectionLeftToRight ~ kCFStringEncodingPrependBOM will probably be deprecated and superceded by kCFStringEncodingPartialInput flag -enum { - kCFStringEncodingAllowLossyConversion = (1UL << 0), // Uses fallback functions to substitutes non mappable chars - kCFStringEncodingBasicDirectionLeftToRight = (1UL << 1), // Converted with original direction left-to-right. - kCFStringEncodingBasicDirectionRightToLeft = (1UL << 2), // Converted with original direction right-to-left. - kCFStringEncodingSubstituteCombinings = (1UL << 3), // Uses fallback function to combining chars. - kCFStringEncodingComposeCombinings = (1UL << 4), // Checks mappable precomposed equivalents for decomposed sequences. This is the default behavior. - kCFStringEncodingIgnoreCombinings = (1UL << 5), // Ignores combining chars. - kCFStringEncodingUseCanonical = (1UL << 6), // Always use canonical form - kCFStringEncodingUseHFSPlusCanonical = (1UL << 7), // Always use canonical form but leaves 0x2000 ranges - kCFStringEncodingPrependBOM = (1UL << 8), // Prepend BOM sequence (i.e. ISO2022KR) - kCFStringEncodingDisableCorporateArea = (1UL << 9), // Disable the usage of 0xF8xx area for Apple proprietary chars in converting to UniChar, resulting loosely mapping. - kCFStringEncodingASCIICompatibleConversion = (1UL << 10), // This flag forces strict ASCII compatible converion. i.e. MacJapanese 0x5C maps to Unicode 0x5C. - kCFStringEncodingLenientUTF8Conversion = (1UL << 11), // 10.1 (Puma) compatible lenient UTF-8 conversion. - kCFStringEncodingPartialInput = (1UL << 12), // input buffer is a part of stream - kCFStringEncodingPartialOutput = (1UL << 13) // output buffer streaming -}; - -/* Return values for CFStringEncodingUnicodeToBytes & CFStringEncodingBytesToUnicode functions -*/ -enum { - kCFStringEncodingConversionSuccess = 0, - kCFStringEncodingInvalidInputStream = 1, - kCFStringEncodingInsufficientOutputBufferLength = 2, - kCFStringEncodingConverterUnavailable = 3 -}; - -/* Macro to shift lossByte argument. -*/ -#define CFStringEncodingLossyByteToMask(lossByte) ((uint32_t)(lossByte << 24)|kCFStringEncodingAllowLossyConversion) -#define CFStringEncodingMaskToLossyByte(flags) ((uint8_t)(flags >> 24)) - -/* Macros for streaming support - */ -#define CFStringEncodingStreamIDMask (0x00FF0000) -#define CFStringEncodingStreamIDFromMask(mask) ((mask >> 16) & 0xFF) -#define CFStringEncodingStreamIDToMask(identifier) ((uint32_t)((identifier & 0xFF) << 16)) - -/* Converts characters into the specified encoding. Returns the constants defined above. -If maxByteLen is 0, bytes is ignored. You can pass lossyByte by passing the value in flags argument. -i.e. CFStringEncodingUnicodeToBytes(encoding, CFStringEncodingLossyByteToMask(lossByte), ....) -*/ -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); - -/* Converts bytes in the specified encoding into unicode. Returns the constants defined above. -maxCharLen & usdCharLen are in UniChar length, not byte length. -If maxCharLen is 0, characters is ignored. -*/ -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); - -/* Fallback functions used when allowLossy -*/ -typedef CFIndex (*CFStringEncodingToBytesFallbackProc)(const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); -typedef CFIndex (*CFStringEncodingToUnicodeFallbackProc)(const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); - -CF_EXPORT bool CFStringEncodingIsValidEncoding(uint32_t encoding); - -/* Returns kCFStringEncodingInvalidId terminated encoding list -*/ -CF_EXPORT const CFStringEncoding *CFStringEncodingListOfAvailableEncodings(void); - -/* Returns required length of destination buffer for conversion. These functions are faster than specifying 0 to maxByteLen (maxCharLen), but unnecessarily optimal length -*/ -CF_EXPORT CFIndex CFStringEncodingCharLengthForBytes(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes); -CF_EXPORT CFIndex CFStringEncodingByteLengthForCharacters(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars); - -/* Can register functions used for lossy conversion. Reregisters default procs if NULL -*/ -CF_EXPORT void CFStringEncodingRegisterFallbackProcedures(uint32_t encoding, CFStringEncodingToBytesFallbackProc toBytes, CFStringEncodingToUnicodeFallbackProc toUnicode); - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERTER__ */ - diff --git a/CFStringEncodingConverter.h b/CFStringEncodingConverter.h new file mode 120000 index 0000000..8af0063 --- /dev/null +++ b/CFStringEncodingConverter.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStringEncodingConverter.h \ No newline at end of file diff --git a/CFStringEncodingConverterExt.h b/CFStringEncodingConverterExt.h deleted file mode 100644 index 1072e43..0000000 --- a/CFStringEncodingConverterExt.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFStringEncodingConverterExt.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__) -#define __COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__ 1 - -#include - -CF_EXTERN_C_BEGIN - -#define MAX_DECOMPOSED_LENGTH (10) - -enum { - kCFStringEncodingConverterStandard = 0, - kCFStringEncodingConverterCheapEightBit = 1, - kCFStringEncodingConverterStandardEightBit = 2, - kCFStringEncodingConverterCheapMultiByte = 3, - kCFStringEncodingConverterPlatformSpecific = 4, // Other fields are ignored - kCFStringEncodingConverterICU = 5 // Other fields are ignored -}; - -/* kCFStringEncodingConverterStandard */ -typedef CFIndex (*CFStringEncodingToBytesProc)(uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); -typedef CFIndex (*CFStringEncodingToUnicodeProc)(uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); -/* kCFStringEncodingConverterCheapEightBit */ -typedef bool (*CFStringEncodingCheapEightBitToBytesProc)(uint32_t flags, UniChar character, uint8_t *byte); -typedef bool (*CFStringEncodingCheapEightBitToUnicodeProc)(uint32_t flags, uint8_t byte, UniChar *character); -/* kCFStringEncodingConverterStandardEightBit */ -typedef uint16_t (*CFStringEncodingStandardEightBitToBytesProc)(uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *byte); -typedef uint16_t (*CFStringEncodingStandardEightBitToUnicodeProc)(uint32_t flags, uint8_t byte, UniChar *characters); -/* kCFStringEncodingConverterCheapMultiByte */ -typedef uint16_t (*CFStringEncodingCheapMultiByteToBytesProc)(uint32_t flags, UniChar character, uint8_t *bytes); -typedef uint16_t (*CFStringEncodingCheapMultiByteToUnicodeProc)(uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *character); - -typedef CFIndex (*CFStringEncodingToBytesLenProc)(uint32_t flags, const UniChar *characters, CFIndex numChars); -typedef CFIndex (*CFStringEncodingToUnicodeLenProc)(uint32_t flags, const uint8_t *bytes, CFIndex numBytes); - -typedef CFIndex (*CFStringEncodingToBytesPrecomposeProc)(uint32_t flags, const UniChar *character, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); -typedef bool (*CFStringEncodingIsValidCombiningCharacterProc)(UniChar character); - -typedef struct { - void *toBytes; - void *toUnicode; - uint16_t maxBytesPerChar; - uint16_t maxDecomposedCharLen; - uint8_t encodingClass; - uint32_t :24; - CFStringEncodingToBytesLenProc toBytesLen; - CFStringEncodingToUnicodeLenProc toUnicodeLen; - CFStringEncodingToBytesFallbackProc toBytesFallback; - CFStringEncodingToUnicodeFallbackProc toUnicodeFallback; - CFStringEncodingToBytesPrecomposeProc toBytesPrecompose; - CFStringEncodingIsValidCombiningCharacterProc isValidCombiningChar; -} CFStringEncodingConverter; - -extern const CFStringEncodingConverter *CFStringEncodingGetConverter(uint32_t encoding); - -enum { - kCFStringEncodingGetConverterSelector = 0, - kCFStringEncodingIsDecomposableCharacterSelector = 1, - kCFStringEncodingDecomposeCharacterSelector = 2, - kCFStringEncodingIsValidLatin1CombiningCharacterSelector = 3, - kCFStringEncodingPrecomposeLatin1CharacterSelector = 4 -}; - -extern const void *CFStringEncodingGetAddressForSelector(uint32_t selector); - -#define BOOTSTRAPFUNC_NAME CFStringEncodingBootstrap -typedef const CFStringEncodingConverter* (*CFStringEncodingBootstrapProc)(uint32_t encoding, const void *getSelector); - -/* Latin precomposition */ -/* This function does not precompose recursively nor to U+01E0 and U+01E1. -*/ -extern bool CFStringEncodingIsValidCombiningCharacterForLatin1(UniChar character); -extern UniChar CFStringEncodingPrecomposeLatinCharacter(const UniChar *character, CFIndex numChars, CFIndex *usedChars); - -/* Convenience functions for converter development */ -typedef struct _CFStringEncodingUnicodeTo8BitCharMap { - UniChar _u; - uint8_t _c; - uint8_t :8; -} CFStringEncodingUnicodeTo8BitCharMap; - -/* Binary searches CFStringEncodingUnicodeTo8BitCharMap */ -CF_INLINE bool CFStringEncodingUnicodeTo8BitEncoding(const CFStringEncodingUnicodeTo8BitCharMap *theTable, CFIndex numElem, UniChar character, uint8_t *ch) { - const CFStringEncodingUnicodeTo8BitCharMap *p, *q, *divider; - - if ((character < theTable[0]._u) || (character > theTable[numElem-1]._u)) { - return 0; - } - p = theTable; - q = p + (numElem-1); - while (p <= q) { - divider = p + ((q - p) >> 1); /* divide by 2 */ - if (character < divider->_u) { q = divider - 1; } - else if (character > divider->_u) { p = divider + 1; } - else { *ch = divider->_c; return 1; } - } - return 0; -} - - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__ */ - diff --git a/CFStringEncodingConverterExt.h b/CFStringEncodingConverterExt.h new file mode 120000 index 0000000..a3ec423 --- /dev/null +++ b/CFStringEncodingConverterExt.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStringEncodingConverterExt.h \ No newline at end of file diff --git a/CFStringEncodingConverterPriv.h b/CFStringEncodingConverterPriv.h deleted file mode 100644 index 30b97df..0000000 --- a/CFStringEncodingConverterPriv.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFStringEncodingConverterPriv.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__) -#define __COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__ 1 - -#include -#include "CFStringEncodingConverterExt.h" - -extern const CFStringEncodingConverter __CFConverterASCII; -extern const CFStringEncodingConverter __CFConverterISOLatin1; -extern const CFStringEncodingConverter __CFConverterMacRoman; -extern const CFStringEncodingConverter __CFConverterWinLatin1; -extern const CFStringEncodingConverter __CFConverterNextStepLatin; -extern const CFStringEncodingConverter __CFConverterUTF8; - -extern CFStringEncoding *__CFStringEncodingCreateListOfAvailablePlatformConverters(CFAllocatorRef allocator, CFIndex *numberOfConverters); -extern const CFStringEncodingConverter *__CFStringEncodingGetExternalConverter(uint32_t encoding); -extern CFIndex __CFStringEncodingPlatformUnicodeToBytes(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars, CFIndex *usedCharLen, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); -extern CFIndex __CFStringEncodingPlatformBytesToUnicode(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, CFIndex *usedByteLen, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); -extern CFIndex __CFStringEncodingPlatformCharLengthForBytes(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes); -extern CFIndex __CFStringEncodingPlatformByteLengthForCharacters(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars); - -#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__ */ - diff --git a/CFStringEncodingConverterPriv.h b/CFStringEncodingConverterPriv.h new file mode 120000 index 0000000..b9e6072 --- /dev/null +++ b/CFStringEncodingConverterPriv.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStringEncodingConverterPriv.h \ No newline at end of file diff --git a/CFStringEncodingDatabase.h b/CFStringEncodingDatabase.h deleted file mode 100644 index 4d4e491..0000000 --- a/CFStringEncodingDatabase.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* - * CFStringEncodingDatabase.h - * CoreFoundation - * - * Created by Aki Inoue on 07/12/05. - * Copyright (c) 2007-2014, Apple Inc. All rights reserved. - * - */ - -#include - -CF_PRIVATE uint16_t __CFStringEncodingGetWindowsCodePage(CFStringEncoding encoding); -CF_PRIVATE CFStringEncoding __CFStringEncodingGetFromWindowsCodePage(uint16_t codepage); - -CF_PRIVATE bool __CFStringEncodingGetCanonicalName(CFStringEncoding encoding, char *buffer, CFIndex bufferSize); -CF_PRIVATE CFStringEncoding __CFStringEncodingGetFromCanonicalName(const char *canonicalName); - -CF_PRIVATE CFStringEncoding __CFStringEncodingGetMostCompatibleMacScript(CFStringEncoding encoding); - -CF_PRIVATE const char *__CFStringEncodingGetName(CFStringEncoding encoding); // Returns simple non-localizd name diff --git a/CFStringEncodingDatabase.h b/CFStringEncodingDatabase.h new file mode 120000 index 0000000..d7ac3cc --- /dev/null +++ b/CFStringEncodingDatabase.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStringEncodingDatabase.h \ No newline at end of file diff --git a/CFStringEncodingExt.h b/CFStringEncodingExt.h deleted file mode 100644 index d11dead..0000000 --- a/CFStringEncodingExt.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFStringEncodingExt.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFSTRINGENCODINGEXT__) -#define __COREFOUNDATION_CFSTRINGENCODINGEXT__ 1 - -#include - -CF_EXTERN_C_BEGIN - -typedef CF_ENUM(CFIndex, CFStringEncodings) { -/* kCFStringEncodingMacRoman = 0L, defined in CoreFoundation/CFString.h */ - kCFStringEncodingMacJapanese = 1, - kCFStringEncodingMacChineseTrad = 2, - kCFStringEncodingMacKorean = 3, - kCFStringEncodingMacArabic = 4, - kCFStringEncodingMacHebrew = 5, - kCFStringEncodingMacGreek = 6, - kCFStringEncodingMacCyrillic = 7, - kCFStringEncodingMacDevanagari = 9, - kCFStringEncodingMacGurmukhi = 10, - kCFStringEncodingMacGujarati = 11, - kCFStringEncodingMacOriya = 12, - kCFStringEncodingMacBengali = 13, - kCFStringEncodingMacTamil = 14, - kCFStringEncodingMacTelugu = 15, - kCFStringEncodingMacKannada = 16, - kCFStringEncodingMacMalayalam = 17, - kCFStringEncodingMacSinhalese = 18, - kCFStringEncodingMacBurmese = 19, - kCFStringEncodingMacKhmer = 20, - kCFStringEncodingMacThai = 21, - kCFStringEncodingMacLaotian = 22, - kCFStringEncodingMacGeorgian = 23, - kCFStringEncodingMacArmenian = 24, - kCFStringEncodingMacChineseSimp = 25, - kCFStringEncodingMacTibetan = 26, - kCFStringEncodingMacMongolian = 27, - kCFStringEncodingMacEthiopic = 28, - kCFStringEncodingMacCentralEurRoman = 29, - kCFStringEncodingMacVietnamese = 30, - kCFStringEncodingMacExtArabic = 31, - /* The following use script code 0, smRoman */ - kCFStringEncodingMacSymbol = 33, - kCFStringEncodingMacDingbats = 34, - kCFStringEncodingMacTurkish = 35, - kCFStringEncodingMacCroatian = 36, - kCFStringEncodingMacIcelandic = 37, - kCFStringEncodingMacRomanian = 38, - kCFStringEncodingMacCeltic = 39, - kCFStringEncodingMacGaelic = 40, - /* The following use script code 4, smArabic */ - kCFStringEncodingMacFarsi = 0x8C, /* Like MacArabic but uses Farsi digits */ - /* The following use script code 7, smCyrillic */ - kCFStringEncodingMacUkrainian = 0x98, - /* The following use script code 32, smUnimplemented */ - kCFStringEncodingMacInuit = 0xEC, - kCFStringEncodingMacVT100 = 0xFC, /* VT100/102 font from Comm Toolbox: Latin-1 repertoire + box drawing etc */ - /* Special Mac OS encodings*/ - kCFStringEncodingMacHFS = 0xFF, /* Meta-value, should never appear in a table */ - - /* Unicode & ISO UCS encodings begin at 0x100 */ - /* We don't use Unicode variations defined in TextEncoding; use the ones in CFString.h, instead. */ - - /* ISO 8-bit and 7-bit encodings begin at 0x200 */ -/* kCFStringEncodingISOLatin1 = 0x0201, defined in CoreFoundation/CFString.h */ - kCFStringEncodingISOLatin2 = 0x0202, /* ISO 8859-2 */ - kCFStringEncodingISOLatin3 = 0x0203, /* ISO 8859-3 */ - kCFStringEncodingISOLatin4 = 0x0204, /* ISO 8859-4 */ - kCFStringEncodingISOLatinCyrillic = 0x0205, /* ISO 8859-5 */ - kCFStringEncodingISOLatinArabic = 0x0206, /* ISO 8859-6, =ASMO 708, =DOS CP 708 */ - kCFStringEncodingISOLatinGreek = 0x0207, /* ISO 8859-7 */ - kCFStringEncodingISOLatinHebrew = 0x0208, /* ISO 8859-8 */ - kCFStringEncodingISOLatin5 = 0x0209, /* ISO 8859-9 */ - kCFStringEncodingISOLatin6 = 0x020A, /* ISO 8859-10 */ - kCFStringEncodingISOLatinThai = 0x020B, /* ISO 8859-11 */ - kCFStringEncodingISOLatin7 = 0x020D, /* ISO 8859-13 */ - kCFStringEncodingISOLatin8 = 0x020E, /* ISO 8859-14 */ - kCFStringEncodingISOLatin9 = 0x020F, /* ISO 8859-15 */ - kCFStringEncodingISOLatin10 = 0x0210, /* ISO 8859-16 */ - - /* MS-DOS & Windows encodings begin at 0x400 */ - kCFStringEncodingDOSLatinUS = 0x0400, /* code page 437 */ - kCFStringEncodingDOSGreek = 0x0405, /* code page 737 (formerly code page 437G) */ - kCFStringEncodingDOSBalticRim = 0x0406, /* code page 775 */ - kCFStringEncodingDOSLatin1 = 0x0410, /* code page 850, "Multilingual" */ - kCFStringEncodingDOSGreek1 = 0x0411, /* code page 851 */ - kCFStringEncodingDOSLatin2 = 0x0412, /* code page 852, Slavic */ - kCFStringEncodingDOSCyrillic = 0x0413, /* code page 855, IBM Cyrillic */ - kCFStringEncodingDOSTurkish = 0x0414, /* code page 857, IBM Turkish */ - kCFStringEncodingDOSPortuguese = 0x0415, /* code page 860 */ - kCFStringEncodingDOSIcelandic = 0x0416, /* code page 861 */ - kCFStringEncodingDOSHebrew = 0x0417, /* code page 862 */ - kCFStringEncodingDOSCanadianFrench = 0x0418, /* code page 863 */ - kCFStringEncodingDOSArabic = 0x0419, /* code page 864 */ - kCFStringEncodingDOSNordic = 0x041A, /* code page 865 */ - kCFStringEncodingDOSRussian = 0x041B, /* code page 866 */ - kCFStringEncodingDOSGreek2 = 0x041C, /* code page 869, IBM Modern Greek */ - kCFStringEncodingDOSThai = 0x041D, /* code page 874, also for Windows */ - kCFStringEncodingDOSJapanese = 0x0420, /* code page 932, also for Windows */ - kCFStringEncodingDOSChineseSimplif = 0x0421, /* code page 936, also for Windows */ - kCFStringEncodingDOSKorean = 0x0422, /* code page 949, also for Windows; Unified Hangul Code */ - kCFStringEncodingDOSChineseTrad = 0x0423, /* code page 950, also for Windows */ -/* kCFStringEncodingWindowsLatin1 = 0x0500, defined in CoreFoundation/CFString.h */ - kCFStringEncodingWindowsLatin2 = 0x0501, /* code page 1250, Central Europe */ - kCFStringEncodingWindowsCyrillic = 0x0502, /* code page 1251, Slavic Cyrillic */ - kCFStringEncodingWindowsGreek = 0x0503, /* code page 1253 */ - kCFStringEncodingWindowsLatin5 = 0x0504, /* code page 1254, Turkish */ - kCFStringEncodingWindowsHebrew = 0x0505, /* code page 1255 */ - kCFStringEncodingWindowsArabic = 0x0506, /* code page 1256 */ - kCFStringEncodingWindowsBalticRim = 0x0507, /* code page 1257 */ - kCFStringEncodingWindowsVietnamese = 0x0508, /* code page 1258 */ - kCFStringEncodingWindowsKoreanJohab = 0x0510, /* code page 1361, for Windows NT */ - - /* Various national standards begin at 0x600 */ -/* kCFStringEncodingASCII = 0x0600, defined in CoreFoundation/CFString.h */ - kCFStringEncodingANSEL = 0x0601, /* ANSEL (ANSI Z39.47) */ - kCFStringEncodingJIS_X0201_76 = 0x0620, - kCFStringEncodingJIS_X0208_83 = 0x0621, - kCFStringEncodingJIS_X0208_90 = 0x0622, - kCFStringEncodingJIS_X0212_90 = 0x0623, - kCFStringEncodingJIS_C6226_78 = 0x0624, - kCFStringEncodingShiftJIS_X0213 CF_ENUM_AVAILABLE(10_5, 2_0) = 0x0628, /* Shift-JIS format encoding of JIS X0213 planes 1 and 2*/ - kCFStringEncodingShiftJIS_X0213_MenKuTen = 0x0629, /* JIS X0213 in plane-row-column notation */ - kCFStringEncodingGB_2312_80 = 0x0630, - kCFStringEncodingGBK_95 = 0x0631, /* annex to GB 13000-93; for Windows 95 */ - kCFStringEncodingGB_18030_2000 = 0x0632, - kCFStringEncodingKSC_5601_87 = 0x0640, /* same as KSC 5601-92 without Johab annex */ - kCFStringEncodingKSC_5601_92_Johab = 0x0641, /* KSC 5601-92 Johab annex */ - kCFStringEncodingCNS_11643_92_P1 = 0x0651, /* CNS 11643-1992 plane 1 */ - kCFStringEncodingCNS_11643_92_P2 = 0x0652, /* CNS 11643-1992 plane 2 */ - kCFStringEncodingCNS_11643_92_P3 = 0x0653, /* CNS 11643-1992 plane 3 (was plane 14 in 1986 version) */ - - /* ISO 2022 collections begin at 0x800 */ - kCFStringEncodingISO_2022_JP = 0x0820, - kCFStringEncodingISO_2022_JP_2 = 0x0821, - kCFStringEncodingISO_2022_JP_1 = 0x0822, /* RFC 2237*/ - kCFStringEncodingISO_2022_JP_3 = 0x0823, /* JIS X0213*/ - kCFStringEncodingISO_2022_CN = 0x0830, - kCFStringEncodingISO_2022_CN_EXT = 0x0831, - kCFStringEncodingISO_2022_KR = 0x0840, - - /* EUC collections begin at 0x900 */ - kCFStringEncodingEUC_JP = 0x0920, /* ISO 646, 1-byte katakana, JIS 208, JIS 212 */ - kCFStringEncodingEUC_CN = 0x0930, /* ISO 646, GB 2312-80 */ - kCFStringEncodingEUC_TW = 0x0931, /* ISO 646, CNS 11643-1992 Planes 1-16 */ - kCFStringEncodingEUC_KR = 0x0940, /* ISO 646, KS C 5601-1987 */ - - /* Misc standards begin at 0xA00 */ - kCFStringEncodingShiftJIS = 0x0A01, /* plain Shift-JIS */ - kCFStringEncodingKOI8_R = 0x0A02, /* Russian internet standard */ - kCFStringEncodingBig5 = 0x0A03, /* Big-5 (has variants) */ - kCFStringEncodingMacRomanLatin1 = 0x0A04, /* Mac OS Roman permuted to align with ISO Latin-1 */ - kCFStringEncodingHZ_GB_2312 = 0x0A05, /* HZ (RFC 1842, for Chinese mail & news) */ - kCFStringEncodingBig5_HKSCS_1999 = 0x0A06, /* Big-5 with Hong Kong special char set supplement*/ - kCFStringEncodingVISCII = 0x0A07, /* RFC 1456, Vietnamese */ - kCFStringEncodingKOI8_U = 0x0A08, /* RFC 2319, Ukrainian */ - kCFStringEncodingBig5_E = 0x0A09, /* Taiwan Big-5E standard */ - - /* Other platform encodings*/ -/* kCFStringEncodingNextStepLatin = 0x0B01, defined in CoreFoundation/CFString.h */ - kCFStringEncodingNextStepJapanese = 0x0B02, /* NextStep Japanese encoding */ - - /* EBCDIC & IBM host encodings begin at 0xC00 */ - kCFStringEncodingEBCDIC_US = 0x0C01, /* basic EBCDIC-US */ - kCFStringEncodingEBCDIC_CP037 = 0x0C02, /* code page 037, extended EBCDIC (Latin-1 set) for US,Canada... */ - - kCFStringEncodingUTF7 CF_ENUM_AVAILABLE(10_6, 4_0) = 0x04000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF7Format RFC2152 */ - kCFStringEncodingUTF7_IMAP CF_ENUM_AVAILABLE(10_6, 4_0) = 0x0A10, /* UTF-7 (IMAP folder variant) RFC3501 */ - - /* Deprecated constants */ - kCFStringEncodingShiftJIS_X0213_00 = 0x0628 /* Shift-JIS format encoding of JIS X0213 planes 1 and 2 (DEPRECATED) */ -}; - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGEXT__ */ - diff --git a/CFStringEncodingExt.h b/CFStringEncodingExt.h new file mode 120000 index 0000000..a1eaa22 --- /dev/null +++ b/CFStringEncodingExt.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStringEncodingExt.h \ No newline at end of file diff --git a/CFStringTokenizer.h b/CFStringTokenizer.h deleted file mode 100644 index 7627ec6..0000000 --- a/CFStringTokenizer.h +++ /dev/null @@ -1,46 +0,0 @@ -#if !defined(__COREFOUNDATION_CFSTRINGTOKENIZER__) -#define __COREFOUNDATION_CFSTRINGTOKENIZER__ 1 - -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct __CFStringTokenizer *CFStringTokenizerRef; - -enum { - kCFStringTokenizerUnitWord = 0, - kCFStringTokenizerUnitSentence = 1, - kCFStringTokenizerUnitParagraph = 2, - kCFStringTokenizerUnitLineBreak = 3, - kCFStringTokenizerUnitWordBoundary = 4, - kCFStringTokenizerAttributeLatinTranscription = 1UL << 16, - kCFStringTokenizerAttributeLanguage = 1UL << 17, -}; - -typedef CF_OPTIONS(CFOptionFlags, CFStringTokenizerTokenType) { - kCFStringTokenizerTokenNone = 0, - kCFStringTokenizerTokenNormal = 1UL << 0, - kCFStringTokenizerTokenHasSubTokensMask = 1UL << 1, - kCFStringTokenizerTokenHasDerivedSubTokensMask = 1UL << 2, - kCFStringTokenizerTokenHasHasNumbersMask = 1UL << 3, - kCFStringTokenizerTokenHasNonLettersMask = 1UL << 4, - kCFStringTokenizerTokenIsCJWordMask = 1UL << 5 -}; - -CF_EXPORT CFStringRef CFStringTokenizerCopyBestStringLanguage(CFStringRef string, CFRange range); -CF_EXPORT CFTypeID CFStringTokenizerGetTypeID(void); -CF_EXPORT CFStringTokenizerRef CFStringTokenizerCreate(CFAllocatorRef alloc, CFStringRef string, CFRange range, CFOptionFlags options, CFLocaleRef locale); -CF_EXPORT void CFStringTokenizerSetString(CFStringTokenizerRef tokenizer, CFStringRef string, CFRange range); -CF_EXPORT CFStringTokenizerTokenType CFStringTokenizerGoToTokenAtIndex(CFStringTokenizerRef tokenizer, CFIndex index); -CF_EXPORT CFStringTokenizerTokenType CFStringTokenizerAdvanceToNextToken(CFStringTokenizerRef tokenizer); -CF_EXPORT CFRange CFStringTokenizerGetCurrentTokenRange(CFStringTokenizerRef tokenizer); -CF_EXPORT CFTypeRef CFStringTokenizerCopyCurrentTokenAttribute(CFStringTokenizerRef tokenizer, CFOptionFlags attribute); -CF_EXPORT CFIndex CFStringTokenizerGetCurrentSubTokens(CFStringTokenizerRef tokenizer, CFRange *ranges, CFIndex maxRangeLength, CFMutableArrayRef derivedSubTokens); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFSTRINGTOKENIZER__ */ diff --git a/CFStringTokenizer.h b/CFStringTokenizer.h new file mode 120000 index 0000000..fef18a9 --- /dev/null +++ b/CFStringTokenizer.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFStringTokenizer.h \ No newline at end of file diff --git a/CFTimeZone.h b/CFTimeZone.h deleted file mode 100644 index 47b3dc2..0000000 --- a/CFTimeZone.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFTimeZone.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFTIMEZONE__) -#define __COREFOUNDATION_CFTIMEZONE__ 1 - -#include -#include -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -CF_EXPORT -CFTypeID CFTimeZoneGetTypeID(void); - -CF_EXPORT -CFTimeZoneRef CFTimeZoneCopySystem(void); - -CF_EXPORT -void CFTimeZoneResetSystem(void); - -CF_EXPORT -CFTimeZoneRef CFTimeZoneCopyDefault(void); - -CF_EXPORT -void CFTimeZoneSetDefault(CFTimeZoneRef tz); - -CF_EXPORT -CFArrayRef CFTimeZoneCopyKnownNames(void); - -CF_EXPORT -CFDictionaryRef CFTimeZoneCopyAbbreviationDictionary(void); - -CF_EXPORT -void CFTimeZoneSetAbbreviationDictionary(CFDictionaryRef dict); - -CF_EXPORT -CFTimeZoneRef CFTimeZoneCreate(CFAllocatorRef allocator, CFStringRef name, CFDataRef data); - -CF_EXPORT -CFTimeZoneRef CFTimeZoneCreateWithTimeIntervalFromGMT(CFAllocatorRef allocator, CFTimeInterval ti); - -CF_EXPORT -CFTimeZoneRef CFTimeZoneCreateWithName(CFAllocatorRef allocator, CFStringRef name, Boolean tryAbbrev); - -CF_EXPORT -CFStringRef CFTimeZoneGetName(CFTimeZoneRef tz); - -CF_EXPORT -CFDataRef CFTimeZoneGetData(CFTimeZoneRef tz); - -CF_EXPORT -CFTimeInterval CFTimeZoneGetSecondsFromGMT(CFTimeZoneRef tz, CFAbsoluteTime at); - -CF_EXPORT -CFStringRef CFTimeZoneCopyAbbreviation(CFTimeZoneRef tz, CFAbsoluteTime at); - -CF_EXPORT -Boolean CFTimeZoneIsDaylightSavingTime(CFTimeZoneRef tz, CFAbsoluteTime at); - -CF_EXPORT -CFTimeInterval CFTimeZoneGetDaylightSavingTimeOffset(CFTimeZoneRef tz, CFAbsoluteTime at) CF_AVAILABLE(10_5, 2_0); - -CF_EXPORT -CFAbsoluteTime CFTimeZoneGetNextDaylightSavingTimeTransition(CFTimeZoneRef tz, CFAbsoluteTime at) CF_AVAILABLE(10_5, 2_0); - -typedef CF_ENUM(CFIndex, CFTimeZoneNameStyle) { - kCFTimeZoneNameStyleStandard, - kCFTimeZoneNameStyleShortStandard, - kCFTimeZoneNameStyleDaylightSaving, - kCFTimeZoneNameStyleShortDaylightSaving, - kCFTimeZoneNameStyleGeneric, - kCFTimeZoneNameStyleShortGeneric -} CF_ENUM_AVAILABLE(10_5, 2_0); - -CF_EXPORT -CFStringRef CFTimeZoneCopyLocalizedName(CFTimeZoneRef tz, CFTimeZoneNameStyle style, CFLocaleRef locale) CF_AVAILABLE(10_5, 2_0); - -CF_EXPORT -const CFStringRef kCFTimeZoneSystemTimeZoneDidChangeNotification CF_AVAILABLE(10_5, 2_0); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFTIMEZONE__ */ - diff --git a/CFTimeZone.h b/CFTimeZone.h new file mode 120000 index 0000000..7de58a2 --- /dev/null +++ b/CFTimeZone.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFTimeZone.h \ No newline at end of file diff --git a/CFTree.h b/CFTree.h deleted file mode 100644 index 278cbc2..0000000 --- a/CFTree.h +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFTree.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ -/*! - @header CFTree - CFTree implements a container which stores references to other CFTrees. - Each tree may have a parent, and a variable number of children. -*/ - -#if !defined(__COREFOUNDATION_CFTREE__) -#define __COREFOUNDATION_CFTREE__ 1 - -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -/*! - @typedef CFTreeRetainCallBack - Type of the callback function used to add a retain to the user-specified - info parameter. This callback may returns the value to use whenever the - info parameter is retained, which is usually the value parameter passed - to this callback, but may be a different value if a different value - should be used. - @param info A user-supplied info parameter provided in a CFTreeContext. - @result The retained info parameter. -*/ -typedef const void * (*CFTreeRetainCallBack)(const void *info); - -/*! - @typedef CFTreeReleaseCallBack - Type of the callback function used to remove a retain previously - added to the user-specified info parameter. - @param info A user-supplied info parameter provided in a CFTreeContext. -*/ -typedef void (*CFTreeReleaseCallBack)(const void *info); - -/*! - @typedef CFTreeCopyDescriptionCallBack - Type of the callback function used to provide a description of the - user-specified info parameter. - @param info A user-supplied info parameter provided in a CFTreeContext. - @result A description of the info parameter. -*/ -typedef CFStringRef (*CFTreeCopyDescriptionCallBack)(const void *info); - -/*! - @typedef CFTreeContext - Structure containing user-specified data and callbacks for a CFTree. - @field version The version number of the structure type being passed - in as a parameter to the CFTree creation function. - This structure is version 0. - @field info A C pointer to a user-specified block of data. - @field retain The callback used to add a retain for the info field. - If this parameter is not a pointer to a function of the correct - prototype, the behavior is undefined. The value may be NULL. - @field release The calllback used to remove a retain previously added - for the info field. If this parameter is not a pointer to a - function of the correct prototype, the behavior is undefined. - The value may be NULL. - @field copyDescription The callback used to provide a description of - the info field. -*/ -typedef struct { - CFIndex version; - void * info; - CFTreeRetainCallBack retain; - CFTreeReleaseCallBack release; - CFTreeCopyDescriptionCallBack copyDescription; -} CFTreeContext; - -/*! - @typedef CFTreeApplierFunction - Type of the callback function used by the apply functions of - CFTree. - @param value The current value from the CFTree - @param context The user-defined context parameter give to the apply - function. -*/ -typedef void (*CFTreeApplierFunction)(const void *value, void *context); - -/*! - @typedef CFTreeRef - This is the type of a reference to CFTrees. -*/ -typedef struct __CFTree * CFTreeRef; - -/*! - @function CFTreeGetTypeID - Returns the type identifier of all CFTree instances. -*/ -CF_EXPORT -CFTypeID CFTreeGetTypeID(void); - -/*! - @function CFTreeCreate - Creates a new mutable tree. - @param allocator The CFAllocator which should be used to allocate - memory for the tree and storage for its children. This - parameter may be NULL in which case the current default - CFAllocator is used. If this reference is not a valid - CFAllocator, the behavior is undefined. - @param context A C pointer to a CFTreeContext structure to be copied - and used as the context of the new tree. The info parameter - will be retained by the tree if a retain function is provided. - If this value is not a valid C pointer to a CFTreeContext - structure-sized block of storage, the result is undefined. - If the version number of the storage is not a valid CFTreeContext - version number, the result is undefined. - @result A reference to the new CFTree. -*/ -CF_EXPORT -CFTreeRef CFTreeCreate(CFAllocatorRef allocator, const CFTreeContext *context); - -/*! - @function CFTreeGetParent - Returns the parent of the specified tree. - @param tree The tree to be queried. If this parameter is not a valid - CFTree, the behavior is undefined. - @result The parent of the tree. -*/ -CF_EXPORT -CFTreeRef CFTreeGetParent(CFTreeRef tree); - -/*! - @function CFTreeGetNextSibling - Returns the sibling after the specified tree in the parent tree's list. - @param tree The tree to be queried. If this parameter is not a valid - CFTree, the behavior is undefined. - @result The next sibling of the tree. -*/ -CF_EXPORT -CFTreeRef CFTreeGetNextSibling(CFTreeRef tree); - -/*! - @function CFTreeGetFirstChild - Returns the first child of the tree. - @param tree The tree to be queried. If this parameter is not a valid - CFTree, the behavior is undefined. - @result The first child of the tree. -*/ -CF_EXPORT -CFTreeRef CFTreeGetFirstChild(CFTreeRef tree); - -/*! - @function CFTreeGetContext - Returns the context of the specified tree. - @param tree The tree to be queried. If this parameter is not a valid - CFTree, the behavior is undefined. - @param context A C pointer to a CFTreeContext structure to be filled in with - the context of the specified tree. If this value is not a valid C - pointer to a CFTreeContext structure-sized block of storage, the - result is undefined. If the version number of the storage is not - a valid CFTreeContext version number, the result is undefined. -*/ -CF_EXPORT -void CFTreeGetContext(CFTreeRef tree, CFTreeContext *context); - -/*! - @function CFTreeGetChildCount - Returns the number of children of the specified tree. - @param tree The tree to be queried. If this parameter is not a valid - CFTree, the behavior is undefined. - @result The number of children. -*/ -CF_EXPORT -CFIndex CFTreeGetChildCount(CFTreeRef tree); - -/*! - @function CFTreeGetChildAtIndex - Returns the nth child of the specified tree. - @param tree The tree to be queried. If this parameter is not a valid - CFTree, the behavior is undefined. - @param idx The index of the child tree to be returned. If this parameter - is less than zero or greater than the number of children of the - tree, the result is undefined. - @result A reference to the specified child tree. -*/ -CF_EXPORT -CFTreeRef CFTreeGetChildAtIndex(CFTreeRef tree, CFIndex idx); - -/*! - @function CFTreeGetChildren - Fills the buffer with children from the tree. - @param tree The tree to be queried. If this parameter is not a valid - CFTree, the behavior is undefined. - @param children A C array of pointer-sized values to be filled with - children from the tree. If this parameter is not a valid pointer to a - C array of at least CFTreeGetChildCount() pointers, the behavior is undefined. - @result A reference to the specified child tree. -*/ -CF_EXPORT -void CFTreeGetChildren(CFTreeRef tree, CFTreeRef *children); - -/*! - @function CFTreeApplyFunctionToChildren - Calls a function once for each child of the tree. Note that the applier - only operates one level deep, and does not operate on descendents further - removed than the immediate children of the tree. - @param heap The tree to be operated upon. If this parameter is not a - valid CFTree, the behavior is undefined. - @param applier The callback function to call once for each child of - the given tree. If this parameter is not a pointer to a - function of the correct prototype, the behavior is undefined. - If there are values in the tree which the applier function does - not expect or cannot properly apply to, the behavior is undefined. - @param context A pointer-sized user-defined value, which is passed - as the second parameter to the applier function, but is - otherwise unused by this function. If the context is not - what is expected by the applier function, the behavior is - undefined. -*/ -CF_EXPORT -void CFTreeApplyFunctionToChildren(CFTreeRef tree, CFTreeApplierFunction applier, void *context); - -/*! - @function CFTreeFindRoot - Returns the root tree of which the specified tree is a descendent. - @param tree The tree to be queried. If this parameter is not a valid - CFTree, the behavior is undefined. - @result A reference to the root of the tree. -*/ -CF_EXPORT -CFTreeRef CFTreeFindRoot(CFTreeRef tree); - -/*! - @function CFTreeSetContext - Replaces the context of a tree. The tree releases its retain on the - info of the previous context, and retains the info of the new context. - @param tree The tree to be operated on. If this parameter is not a valid - CFTree, the behavior is undefined. - @param context A C pointer to a CFTreeContext structure to be copied - and used as the context of the new tree. The info parameter - will be retained by the tree if a retain function is provided. - If this value is not a valid C pointer to a CFTreeContext - structure-sized block of storage, the result is undefined. - If the version number of the storage is not a valid CFTreeContext - version number, the result is undefined. -*/ -CF_EXPORT -void CFTreeSetContext(CFTreeRef tree, const CFTreeContext *context); - -/*! - @function CFTreePrependChild - Adds the newChild to the specified tree as the first in its list of children. - @param tree The tree to be operated on. If this parameter is not a valid - CFTree, the behavior is undefined. - @param newChild The child to be added. - If this parameter is not a valid CFTree, the behavior is undefined. - If this parameter is a tree which is already a child of any tree, - the behavior is undefined. -*/ -CF_EXPORT -void CFTreePrependChild(CFTreeRef tree, CFTreeRef newChild); - -/*! - @function CFTreeAppendChild - Adds the newChild to the specified tree as the last in its list of children. - @param tree The tree to be operated on. If this parameter is not a valid - CFTree, the behavior is undefined. - @param newChild The child to be added. - If this parameter is not a valid CFTree, the behavior is undefined. - If this parameter is a tree which is already a child of any tree, - the behavior is undefined. -*/ -CF_EXPORT -void CFTreeAppendChild(CFTreeRef tree, CFTreeRef newChild); - -/*! - @function CFTreeInsertSibling - Inserts newSibling into the the parent tree's linked list of children after - tree. The newSibling will have the same parent as tree. - @param tree The tree to insert newSibling after. If this parameter is not a valid - CFTree, the behavior is undefined. If the tree does not have a - parent, the behavior is undefined. - @param newSibling The sibling to be added. - If this parameter is not a valid CFTree, the behavior is undefined. - If this parameter is a tree which is already a child of any tree, - the behavior is undefined. -*/ -CF_EXPORT -void CFTreeInsertSibling(CFTreeRef tree, CFTreeRef newSibling); - -/*! - @function CFTreeRemove - Removes the tree from its parent. - @param tree The tree to be removed. If this parameter is not a valid - CFTree, the behavior is undefined. -*/ -CF_EXPORT -void CFTreeRemove(CFTreeRef tree); - -/*! - @function CFTreeRemoveAllChildren - Removes all the children of the tree. - @param tree The tree to remove all children from. If this parameter is not a valid - CFTree, the behavior is undefined. -*/ -CF_EXPORT -void CFTreeRemoveAllChildren(CFTreeRef tree); - -/*! - @function CFTreeSortChildren - Sorts the children of the specified tree using the specified comparator function. - @param tree The tree to be operated on. If this parameter is not a valid - CFTree, the behavior is undefined. - @param comparator The function with the comparator function type - signature which is used in the sort operation to compare - children of the tree with the given value. If this parameter - is not a pointer to a function of the correct prototype, the - the behavior is undefined. The children of the tree are sorted - from least to greatest according to this function. - @param context A pointer-sized user-defined value, which is passed - as the third parameter to the comparator function, but is - otherwise unused by this function. If the context is not - what is expected by the comparator function, the behavior is - undefined. -*/ -CF_EXPORT -void CFTreeSortChildren(CFTreeRef tree, CFComparatorFunction comparator, void *context); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFTREE__ */ - diff --git a/CFTree.h b/CFTree.h new file mode 120000 index 0000000..a659ea9 --- /dev/null +++ b/CFTree.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFTree.h \ No newline at end of file diff --git a/CFURL.h b/CFURL.h deleted file mode 100644 index 6b6d95f..0000000 --- a/CFURL.h +++ /dev/null @@ -1,1160 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFURL.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFURL__) -#define __COREFOUNDATION_CFURL__ 1 - -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef CF_ENUM(CFIndex, CFURLPathStyle) { - kCFURLPOSIXPathStyle = 0, - kCFURLHFSPathStyle CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0), /* The use of kCFURLHFSPathStyle is deprecated. The Carbon File Manager, which uses HFS style paths, is deprecated. HFS style paths are unreliable because they can arbitrarily refer to multiple volumes if those volumes have identical volume names. You should instead use kCFURLPOSIXPathStyle wherever possible. */ - kCFURLWindowsPathStyle -}; - -typedef const struct CF_BRIDGED_TYPE(NSURL) __CFURL * CFURLRef; - -/* CFURLs are composed of two fundamental pieces - their string, and a */ -/* (possibly NULL) base URL. A relative URL is one in which the string */ -/* by itself does not fully specify the URL (for instance "myDir/image.tiff"); */ -/* an absolute URL is one in which the string does fully specify the URL */ -/* ("file://localhost/myDir/image.tiff"). Absolute URLs always have NULL */ -/* base URLs; however, it is possible for a URL to have a NULL base, and still */ -/* not be absolute. Such a URL has only a relative string, and cannot be */ -/* resolved. Two CFURLs are considered equal if and only if their strings */ -/* are equal and their bases are equal. In other words, */ -/* "file://localhost/myDir/image.tiff" is NOT equal to the URL with relative */ -/* string "myDir/image.tiff" and base URL "file://localhost/". Clients that */ -/* need these less strict form of equality should convert all URLs to their */ -/* absolute form via CFURLCopyAbsoluteURL(), then compare the absolute forms. */ - -CF_EXPORT -CFTypeID CFURLGetTypeID(void); - -/* encoding will be used both to interpret the bytes of URLBytes, and to */ -/* interpret any percent-escapes within the bytes. */ -/* Using a string encoding which isn't a superset of ASCII encoding is not */ -/* supported because CFURLGetBytes and CFURLGetByteRangeForComponent require */ -/* 7-bit ASCII characters to be stored in a single 8-bit byte. */ -/* CFStringEncodings which are a superset of ASCII encoding include MacRoman, */ -/* WindowsLatin1, ISOLatin1, NextStepLatin, ASCII, and UTF8. */ -CF_EXPORT -CFURLRef CFURLCreateWithBytes(CFAllocatorRef allocator, const UInt8 *URLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL); - -/* Escapes any character that is not 7-bit ASCII with the byte-code */ -/* for the given encoding. If escapeWhitespace is true, whitespace */ -/* characters (' ', '\t', '\r', '\n') will be escaped also (desirable */ -/* if embedding the URL into a larger text stream like HTML) */ -CF_EXPORT -CFDataRef CFURLCreateData(CFAllocatorRef allocator, CFURLRef url, CFStringEncoding encoding, Boolean escapeWhitespace); - -/* Any escape sequences in URLString will be interpreted via UTF-8. */ -CF_EXPORT -CFURLRef CFURLCreateWithString(CFAllocatorRef allocator, CFStringRef URLString, CFURLRef baseURL); - -/* Create an absolute URL directly, without requiring the extra step */ -/* of calling CFURLCopyAbsoluteURL(). If useCompatibilityMode is */ -/* true, the rules historically used on the web are used to resolve */ -/* relativeString against baseURL - these rules are generally listed */ -/* in the RFC as optional or alternate interpretations. Otherwise, */ -/* the strict rules from the RFC are used. The major differences are */ -/* that in compatibility mode, we are lenient of the scheme appearing */ -/* in relative portion, leading "../" components are removed from the */ -/* final URL's path, and if the relative portion contains only */ -/* resource specifier pieces (query, parameters, and fragment), then */ -/* the last path component of the base URL will not be deleted. */ -/* Using a string encoding which isn't a superset of ASCII encoding is not */ -/* supported because CFURLGetBytes and CFURLGetByteRangeForComponent require */ -/* 7-bit ASCII characters to be stored in a single 8-bit byte. */ -/* CFStringEncodings which are a superset of ASCII encoding include MacRoman, */ -/* WindowsLatin1, ISOLatin1, NextStepLatin, ASCII, and UTF8. */ -CF_EXPORT -CFURLRef CFURLCreateAbsoluteURLWithBytes(CFAllocatorRef alloc, const UInt8 *relativeURLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL, Boolean useCompatibilityMode); - -/* filePath should be the URL's path expressed as a path of the type */ -/* fsType. If filePath is not absolute, the resulting URL will be */ -/* considered relative to the current working directory (evaluated */ -/* at creation time). isDirectory determines whether filePath is */ -/* treated as a directory path when resolving against relative path */ -/* components */ -CF_EXPORT -CFURLRef CFURLCreateWithFileSystemPath(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory); - -CF_EXPORT -CFURLRef CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory); - -/* The path style of the baseURL must match the path style of the relative */ -/* url or the results are undefined. If the provided filePath looks like an */ -/* absolute path ( starting with '/' if pathStyle is kCFURLPosixPathStyle, */ -/* not starting with ':' for kCFURLHFSPathStyle, or starting with what looks */ -/* like a drive letter and colon for kCFURLWindowsPathStyle ) then the baseURL */ -/* is ignored. */ -CF_EXPORT -CFURLRef CFURLCreateWithFileSystemPathRelativeToBase(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL); - -CF_EXPORT -CFURLRef CFURLCreateFromFileSystemRepresentationRelativeToBase(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory, CFURLRef baseURL); - -/* Fills buffer with the file system's native representation of */ -/* url's path. No more than maxBufLen bytes are written to buffer. */ -/* The buffer should be at least the maximum path length for */ -/* the file system in question to avoid failures for insufficiently */ -/* large buffers. If resolveAgainstBase is true, the url's relative */ -/* portion is resolved against its base before the path is computed. */ -/* Returns success or failure. */ -CF_EXPORT -Boolean CFURLGetFileSystemRepresentation(CFURLRef url, Boolean resolveAgainstBase, UInt8 *buffer, CFIndex maxBufLen); - -/* Creates a new URL by resolving the relative portion of relativeURL against its base. */ -CF_EXPORT -CFURLRef CFURLCopyAbsoluteURL(CFURLRef relativeURL); - -/* Returns the URL's string. */ -CF_EXPORT -CFStringRef CFURLGetString(CFURLRef anURL); - -/* Returns the base URL if it exists */ -CF_EXPORT -CFURLRef CFURLGetBaseURL(CFURLRef anURL); - -/* -All URLs can be broken into two pieces - the scheme (preceding the -first colon) and the resource specifier (following the first colon). -Most URLs are also "standard" URLs conforming to RFC 1808 (available -from www.w3c.org). This category includes URLs of the file, http, -https, and ftp schemes, to name a few. Standard URLs start the -resource specifier with two slashes ("//"), and can be broken into -four distinct pieces - the scheme, the net location, the path, and -further resource specifiers (typically an optional parameter, query, -and/or fragment). The net location appears immediately following -the two slashes and goes up to the next slash; it's format is -scheme-specific, but is usually composed of some or all of a username, -password, host name, and port. The path is a series of path components -separated by slashes; if the net location is present, the path always -begins with a slash. Standard URLs can be relative to another URL, -in which case at least the scheme and possibly other pieces as well -come from the base URL (see RFC 1808 for precise details when resolving -a relative URL against its base). The full URL is therefore - - "://" - -If a given CFURL can be decomposed (that is, conforms to RFC 1808), you -can ask for each of the four basic pieces (scheme, net location, path, -and resource specifer) separately, as well as for its base URL. The -basic pieces are returned with any percent escape sequences still in -place (although note that the scheme may not legally include any -percent escapes); this is to allow the caller to distinguish between -percent sequences that may have syntactic meaning if replaced by the -character being escaped (for instance, a '/' in a path component). -Since only the individual schemes know which characters are -syntactically significant, CFURL cannot safely replace any percent -escape sequences. However, you can use -CFURLCreateStringByReplacingPercentEscapes() to create a new string with -the percent escapes removed; see below. - -If a given CFURL can not be decomposed, you can ask for its scheme and its -resource specifier; asking it for its net location or path will return NULL. - -To get more refined information about the components of a decomposable -CFURL, you may ask for more specific pieces of the URL, expressed with -the percent escapes removed. The available functions are CFURLCopyHostName(), -CFURLGetPortNumber() (returns an Int32), CFURLCopyUserName(), -CFURLCopyPassword(), CFURLCopyQuery(), CFURLCopyParameters(), and -CFURLCopyFragment(). Because the parameters, query, and fragment of an -URL may contain scheme-specific syntaxes, these methods take a second -argument, giving a list of characters which should NOT be replaced if -percent escaped. For instance, the ftp parameter syntax gives simple -key-value pairs as "=;" Clearly if a key or value includes -either '=' or ';', it must be escaped to avoid corrupting the meaning of -the parameters, so the caller may request the parameter string as - -CFStringRef myParams = CFURLCopyParameters(ftpURL, CFSTR("=;%")); - -requesting that all percent escape sequences be replaced by the represented -characters, except for escaped '=', '%' or ';' characters. Pass the empty -string (CFSTR("")) to request that all percent escapes be replaced, or NULL -to request that none be. -*/ - -/* Returns true if anURL conforms to RFC 1808 */ -CF_EXPORT -Boolean CFURLCanBeDecomposed(CFURLRef anURL); - -/* The next several methods leave any percent escape sequences intact */ - -CF_EXPORT -CFStringRef CFURLCopyScheme(CFURLRef anURL); - -/* NULL if CFURLCanBeDecomposed(anURL) is false */ -CF_EXPORT -CFStringRef CFURLCopyNetLocation(CFURLRef anURL); - -/* NULL if CFURLCanBeDecomposed(anURL) is false; also does not resolve the URL */ -/* against its base. See also CFURLCopyAbsoluteURL(). Note that, strictly */ -/* speaking, any leading '/' is not considered part of the URL's path, although */ -/* its presence or absence determines whether the path is absolute. */ -/* CFURLCopyPath()'s return value includes any leading slash (giving the path */ -/* the normal POSIX appearance); CFURLCopyStrictPath()'s return value omits any */ -/* leading slash, and uses isAbsolute to report whether the URL's path is absolute. */ - -/* CFURLCopyFileSystemPath() returns the URL's path as a file system path for the */ -/* given path style. All percent escape sequences are replaced. The URL is not */ -/* resolved against its base before computing the path. */ -CF_EXPORT -CFStringRef CFURLCopyPath(CFURLRef anURL); - -CF_EXPORT -CFStringRef CFURLCopyStrictPath(CFURLRef anURL, Boolean *isAbsolute); - -CF_EXPORT -CFStringRef CFURLCopyFileSystemPath(CFURLRef anURL, CFURLPathStyle pathStyle); - -/* Returns whether anURL's path represents a directory */ -/* (true returned) or a simple file (false returned) */ -CF_EXPORT -Boolean CFURLHasDirectoryPath(CFURLRef anURL); - -/* Any additional resource specifiers after the path. For URLs */ -/* that cannot be decomposed, this is everything except the scheme itself. */ -CF_EXPORT -CFStringRef CFURLCopyResourceSpecifier(CFURLRef anURL); - -CF_EXPORT -CFStringRef CFURLCopyHostName(CFURLRef anURL); - -CF_EXPORT -SInt32 CFURLGetPortNumber(CFURLRef anURL); /* Returns -1 if no port number is specified */ - -CF_EXPORT -CFStringRef CFURLCopyUserName(CFURLRef anURL); - -CF_EXPORT -CFStringRef CFURLCopyPassword(CFURLRef anURL); - -/* These remove all percent escape sequences except those for */ -/* characters in charactersToLeaveEscaped. If charactersToLeaveEscaped */ -/* is empty (""), all percent escape sequences are replaced by their */ -/* corresponding characters. If charactersToLeaveEscaped is NULL, */ -/* then no escape sequences are removed at all */ -CF_EXPORT -CFStringRef CFURLCopyParameterString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped); - -CF_EXPORT -CFStringRef CFURLCopyQueryString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped); - -CF_EXPORT -CFStringRef CFURLCopyFragment(CFURLRef anURL, CFStringRef charactersToLeaveEscaped); - -CF_EXPORT -CFStringRef CFURLCopyLastPathComponent(CFURLRef url); - -CF_EXPORT -CFStringRef CFURLCopyPathExtension(CFURLRef url); - -/* These functions all treat the base URL of the supplied url as */ -/* invariant. In other words, the URL returned will always have */ -/* the same base as the URL supplied as an argument. */ - -CF_EXPORT -CFURLRef CFURLCreateCopyAppendingPathComponent(CFAllocatorRef allocator, CFURLRef url, CFStringRef pathComponent, Boolean isDirectory); - -CF_EXPORT -CFURLRef CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator, CFURLRef url); - -CF_EXPORT -CFURLRef CFURLCreateCopyAppendingPathExtension(CFAllocatorRef allocator, CFURLRef url, CFStringRef extension); - -CF_EXPORT -CFURLRef CFURLCreateCopyDeletingPathExtension(CFAllocatorRef allocator, CFURLRef url); - -/* Fills buffer with the bytes for url, returning the number of bytes */ -/* filled. If buffer is of insufficient size, returns -1 and no bytes */ -/* are placed in buffer. If buffer is NULL, the needed length is */ -/* computed and returned. The returned bytes are the original bytes */ -/* from which the URL was created; if the URL was created from a */ -/* string, the bytes will be the bytes of the string encoded via UTF-8 */ -CF_EXPORT -CFIndex CFURLGetBytes(CFURLRef url, UInt8 *buffer, CFIndex bufferLength); - -typedef CF_ENUM(CFIndex, CFURLComponentType) { - kCFURLComponentScheme = 1, - kCFURLComponentNetLocation = 2, - kCFURLComponentPath = 3, - kCFURLComponentResourceSpecifier = 4, - - kCFURLComponentUser = 5, - kCFURLComponentPassword = 6, - kCFURLComponentUserInfo = 7, - kCFURLComponentHost = 8, - kCFURLComponentPort = 9, - kCFURLComponentParameterString = 10, - kCFURLComponentQuery = 11, - kCFURLComponentFragment = 12 -}; - -/* -Gets the range of the requested component in the bytes of url, as -returned by CFURLGetBytes(). This range is only good for use in the -bytes returned by CFURLGetBytes! - -If non-NULL, rangeIncludingSeparators gives the range of component -including the sequences that separate component from the previous and -next components. If there is no previous or next component, that end of -rangeIncludingSeparators will match the range of the component itself. -If url does not contain the given component type, (kCFNotFound, 0) is -returned, and rangeIncludingSeparators is set to the location where the -component would be inserted. Some examples - - -For the URL http://www.apple.com/hotnews/ - -Component returned range rangeIncludingSeparators -scheme (0, 4) (0, 7) -net location (7, 13) (4, 16) -path (20, 9) (20, 9) -resource specifier (kCFNotFound, 0) (29, 0) -user (kCFNotFound, 0) (7, 0) -password (kCFNotFound, 0) (7, 0) -user info (kCFNotFound, 0) (7, 0) -host (7, 13) (4, 16) -port (kCFNotFound, 0) (20, 0) -parameter (kCFNotFound, 0) (29, 0) -query (kCFNotFound, 0) (29, 0) -fragment (kCFNotFound, 0) (29, 0) - - -For the URL ./relPath/file.html#fragment - -Component returned range rangeIncludingSeparators -scheme (kCFNotFound, 0) (0, 0) -net location (kCFNotFound, 0) (0, 0) -path (0, 19) (0, 20) -resource specifier (20, 8) (19, 9) -user (kCFNotFound, 0) (0, 0) -password (kCFNotFound, 0) (0, 0) -user info (kCFNotFound, 0) (0, 0) -host (kCFNotFound, 0) (0, 0) -port (kCFNotFound, 0) (0, 0) -parameter (kCFNotFound, 0) (19, 0) -query (kCFNotFound, 0) (19, 0) -fragment (20, 8) (19, 9) - - -For the URL scheme://user:pass@host:1/path/path2/file.html;params?query#fragment - -Component returned range rangeIncludingSeparators -scheme (0, 6) (0, 9) -net location (9, 16) (6, 19) -path (25, 21) (25, 22) -resource specifier (47, 21) (46, 22) -user (9, 4) (6, 8) -password (14, 4) (13, 6) -user info (9, 9) (6, 13) -host (19, 4) (18, 6) -port (24, 1) (23, 2) -parameter (47, 6) (46, 8) -query (54, 5) (53, 7) -fragment (60, 8) (59, 9) -*/ -CF_EXPORT -CFRange CFURLGetByteRangeForComponent(CFURLRef url, CFURLComponentType component, CFRange *rangeIncludingSeparators); - -/* Returns a string with any percent escape sequences that do NOT */ -/* correspond to characters in charactersToLeaveEscaped with their */ -/* equivalent. Returns NULL on failure (if an invalid percent sequence */ -/* is encountered), or the original string (retained) if no characters */ -/* need to be replaced. Pass NULL to request that no percent escapes be */ -/* replaced, or the empty string (CFSTR("")) to request that all percent */ -/* escapes be replaced. Uses UTF8 to interpret percent escapes. */ -CF_EXPORT -CFStringRef CFURLCreateStringByReplacingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveEscaped); - -/* As above, but allows you to specify the encoding to use when interpreting percent escapes */ -CF_EXPORT -CFStringRef CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFAllocatorRef allocator, CFStringRef origString, CFStringRef charsToLeaveEscaped, CFStringEncoding encoding); - -/* Creates a copy or originalString, replacing certain characters with */ -/* the equivalent percent escape sequence based on the encoding specified. */ -/* If the originalString does not need to be modified (no percent escape */ -/* sequences are missing), may retain and return originalString. */ -/* If you are uncertain of the correct encoding, you should use UTF-8, */ -/* which is the encoding designated by RFC 2396 as the correct encoding */ -/* for use in URLs. The characters so escaped are all characters that */ -/* are not legal URL characters (based on RFC 2396), plus any characters */ -/* in legalURLCharactersToBeEscaped, less any characters in */ -/* charactersToLeaveUnescaped. To simply correct any non-URL characters */ -/* in an otherwise correct URL string, do: */ - -/* newString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, origString, NULL, NULL, kCFStringEncodingUTF8); */ -CF_EXPORT -CFStringRef CFURLCreateStringByAddingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding); - - -#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION -CF_IMPLICIT_BRIDGING_DISABLED - -/* - CFURLIsFileReferenceURL - - Returns whether the URL is a file reference URL. - - Parameters - url - The URL specifying the resource. - */ -CF_EXPORT -Boolean CFURLIsFileReferenceURL(CFURLRef url) CF_AVAILABLE(10_9, 7_0); - -/* - CFURLCreateFileReferenceURL - - Returns a new file reference URL that refers to the same resource as a specified URL. - - Parameters - allocator - The memory allocator for creating the new URL. - url - The file URL specifying the resource. - error - On output when the result is NULL, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. - - Return Value - The new file reference URL, or NULL if an error occurs. - - Discussion - File reference URLs use a URL path syntax that identifies a file system object by reference, not by path. This form of file URL remains valid when the file system path of the URL’s underlying resource changes. An error will occur if the url parameter is not a file URL. File reference URLs cannot be created to file system objects which do not exist or are not reachable. In some areas of the file system hierarchy, file reference URLs cannot be generated to the leaf node of the URL path. A file reference URL's path should never be persistently stored because is not valid across system restarts, and across remounts of volumes -- if you want to create a persistent reference to a file system object, use a bookmark (see CFURLCreateBookmarkData). If this function returns NULL, the optional error is populated. This function is currently applicable only to URLs for file system resources. - Symbol is present in iOS 4, but performs no operation. - */ -CF_EXPORT -CFURLRef CFURLCreateFileReferenceURL(CFAllocatorRef allocator, CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - - -/* - CFURLCreateFilePathURL - - Returns a new file path URL that refers to the same resource as a specified URL. - - Parameters - allocator - The memory allocator for creating the new URL. - url - The file URL specifying the resource. - error - On output when the result is NULL, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. - - Return Value - The new file path URL, or NULL if an error occurs. - - Discussion - File path URLs use a file system style path. An error will occur if the url parameter is not a file URL. A file reference URL's resource must exist and be reachable to be converted to a file path URL. If this function returns NULL, the optional error is populated. This function is currently applicable only to URLs for file system resources. - Symbol is present in iOS 4, but performs no operation. - */ -CF_EXPORT -CFURLRef CFURLCreateFilePathURL(CFAllocatorRef allocator, CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - -CF_IMPLICIT_BRIDGING_ENABLED -#endif - - - -#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION -CF_IMPLICIT_BRIDGING_DISABLED - -/* Resource access - - The behavior of resource value caching is slightly different between the NSURL and CFURL API. - - When the NSURL methods which get, set, or use cached resource values are used from the main thread, resource values cached by the URL (except those added as temporary properties) are invalidated the next time the main thread's run loop runs. - - The CFURL functions do not automatically clear any resource values cached by the URL. The client has complete control over the cache lifetime. If you are using CFURL API, you must use CFURLClearResourcePropertyCacheForKey or CFURLClearResourcePropertyCache to clear cached resource values. - */ - - -/* - CFURLCopyResourcePropertyForKey - - Returns the resource value identified by a given resource key. - - Parameters - url - The URL specifying the resource. - key - The resource key that identifies the resource property. - propertyValueTypeRefPtr - On output when the result is true, the resource value or NULL. - error - On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. - - Return Value - true if propertyValueTypeRefPtr is successfully populated; false if an error occurs. - - Discussion - CFURLCopyResourcePropertyForKey first checks if the URL object already caches the resource value. If so, it returns the cached resource value to the caller. If not, then CFURLCopyResourcePropertyForKey synchronously obtains the resource value from the backing store, adds the resource value to the URL object's cache, and returns the resource value to the caller. The type of the resource value varies by resource property (see resource key definitions). If this function returns true and propertyValueTypeRefPtr is populated with NULL, it means the resource property is not available for the specified resource and no errors occurred when determining the resource property was not available. If this function returns false, the optional error is populated. This function is currently applicable only to URLs for file system resources. - Symbol is present in iOS 4, but performs no operation. - */ -CF_EXPORT -Boolean CFURLCopyResourcePropertyForKey(CFURLRef url, CFStringRef key, void *propertyValueTypeRefPtr, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - - -/* - CFURLCopyResourcePropertiesForKeys - - Returns the resource values identified by specified array of resource keys. - - Parameters - url - The URL specifying the resource. - keys - An array of resource keys that identify the resource properties. - error - On output when the result is NULL, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. - - Return Value - A dictionary of resource values indexed by resource key; NULL if an error occurs. - - Discussion - CFURLCopyResourcePropertiesForKeys first checks if the URL object already caches the resource values. If so, it returns the cached resource values to the caller. If not, then CFURLCopyResourcePropertyForKey synchronously obtains the resource values from the backing store, adds the resource values to the URL object's cache, and returns the resource values to the caller. The type of the resource values vary by property (see resource key definitions). If the result dictionary does not contain a resource value for one or more of the requested resource keys, it means those resource properties are not available for the specified resource and no errors occurred when determining those resource properties were not available. If this function returns NULL, the optional error is populated. This function is currently applicable only to URLs for file system resources. - Symbol is present in iOS 4, but performs no operation. - */ -CF_EXPORT -CFDictionaryRef CFURLCopyResourcePropertiesForKeys(CFURLRef url, CFArrayRef keys, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - - -/* - CFURLSetResourcePropertyForKey - - Sets the resource value identified by a given resource key. - - Parameters - url - The URL specifying the resource. - key - The resource key that identifies the resource property. - propertyValue - The resource value. - error - On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. - - Return Value - true if the attempt to set the resource value completed with no errors; otherwise, false. - - Discussion - CFURLSetResourcePropertyForKey writes the new resource value out to the backing store. Attempts to set a read-only resource property or to set a resource property not supported by the resource are ignored and are not considered errors. If this function returns false, the optional error is populated. This function is currently applicable only to URLs for file system resources. - Symbol is present in iOS 4, but performs no operation. - */ -CF_EXPORT -Boolean CFURLSetResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - - -/* - CFURLSetResourcePropertiesForKeys - - Sets any number of resource values of a URL's resource. - - Parameters - url - The URL specifying the resource. - keyedPropertyValues - A dictionary of resource values indexed by resource keys. - error - On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. - - Return Value - true if the attempt to set the resource values completed with no errors; otherwise, false. - - Discussion - CFURLSetResourcePropertiesForKeys writes the new resource values out to the backing store. Attempts to set read-only resource properties or to set resource properties not supported by the resource are ignored and are not considered errors. If an error occurs after some resource properties have been successfully changed, the userInfo dictionary in the returned error contains an array of resource keys that were not set with the key kCFURLKeysOfUnsetValuesKey. The order in which the resource values are set is not defined. If you need to guarantee the order resource values are set, you should make multiple requests to CFURLSetResourcePropertiesForKeys or CFURLSetResourcePropertyForKey to guarantee the order. If this function returns false, the optional error is populated. This function is currently applicable only to URLs for file system resources. - Symbol is present in iOS 4, but performs no operation. - */ -CF_EXPORT -Boolean CFURLSetResourcePropertiesForKeys(CFURLRef url, CFDictionaryRef keyedPropertyValues, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - - -CF_EXPORT -const CFStringRef kCFURLKeysOfUnsetValuesKey CF_AVAILABLE(10_7, 5_0); - /* Key for the resource properties that have not been set after the CFURLSetResourcePropertiesForKeys function returns an error, returned as an array of of CFString objects. */ - - -/* - CFURLClearResourcePropertyCacheForKey - - Discards a cached resource value of a URL. - - Parameters - url - The URL specifying the resource. - key - The resource key that identifies the resource property. - - Discussion - Discarding a cached resource value may discard other cached resource values, because some resource values are cached as a set of values and because some resource values depend on other resource values (temporary properties have no dependencies). This function is currently applicable only to URLs for file system resources. - Symbol is present in iOS 4, but performs no operation. - */ -CF_EXPORT -void CFURLClearResourcePropertyCacheForKey(CFURLRef url, CFStringRef key) CF_AVAILABLE(10_6, 4_0); - - -/* - CFURLClearResourcePropertyCache - - Discards all cached resource values of a URL. - - Parameters - url - The URL specifying the resource. - - Discussion - All temporary properties are also cleared from the URL object's cache. This function is currently applicable only to URLs for file system resources. - Symbol is present in iOS 4, but performs no operation. - */ -CF_EXPORT -void CFURLClearResourcePropertyCache(CFURLRef url) CF_AVAILABLE(10_6, 4_0); - - -/* - CFURLSetTemporaryResourcePropertyForKey - - Sets a temporary resource value on the URL object. - - Parameters - url - The URL object. - key - The resource key that identifies the temporary resource property. - propertyValue - The resource value. - - Discussion - Temporary properties are for client use. Temporary properties exist only in memory and are never written to the resource's backing store. Once set, a temporary value can be copied from the URL object with CFURLCopyResourcePropertyForKey and CFURLCopyResourcePropertiesForKeys. To remove a temporary value from the URL object, use CFURLClearResourcePropertyCacheForKey. Temporary values must be valid Core Foundation types, and will be retained by CFURLSetTemporaryResourcePropertyForKey. Care should be taken to ensure the key that identifies a temporary resource property is unique and does not conflict with system defined keys (using reverse domain name notation in your temporary resource property keys is recommended). This function is currently applicable only to URLs for file system resources. - Symbol is present in iOS 4, but performs no operation. - */ -CF_EXPORT -void CFURLSetTemporaryResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue) CF_AVAILABLE(10_6, 4_0); - - -/* - CFURLResourceIsReachable - - Returns whether the URL's resource exists and is reachable. - - Parameters - url - The URL object. - error - On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. - - Return Value - true if the resource is reachable; otherwise, false. - - Discussion - CFURLResourceIsReachable synchronously checks if the resource's backing store is reachable. Checking reachability is appropriate when making decisions that do not require other immediate operations on the resource, e.g. periodic maintenance of UI state that depends on the existence of a specific document. When performing operations such as opening a file or copying resource properties, it is more efficient to simply try the operation and handle failures. This function is currently applicable only to URLs for file system resources. If this function returns false, the optional error is populated. For other URL types, false is returned. - Symbol is present in iOS 4, but performs no operation. - */ -CF_EXPORT -Boolean CFURLResourceIsReachable(CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - -CF_IMPLICIT_BRIDGING_ENABLED - - -/* Properties of File System Resources */ - -CF_EXPORT -const CFStringRef kCFURLNameKey CF_AVAILABLE(10_6, 4_0); - /* The resource name provided by the file system (Read-write, value type CFString) */ - -CF_EXPORT -const CFStringRef kCFURLLocalizedNameKey CF_AVAILABLE(10_6, 4_0); - /* Localized or extension-hidden name as displayed to users (Read-only, value type CFString) */ - -CF_EXPORT -const CFStringRef kCFURLIsRegularFileKey CF_AVAILABLE(10_6, 4_0); - /* True for regular files (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLIsDirectoryKey CF_AVAILABLE(10_6, 4_0); - /* True for directories (Read-only, CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLIsSymbolicLinkKey CF_AVAILABLE(10_6, 4_0); - /* True for symlinks (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLIsVolumeKey CF_AVAILABLE(10_6, 4_0); - /* True for the root directory of a volume (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLIsPackageKey CF_AVAILABLE(10_6, 4_0); - /* True for packaged directories (Read-only 10_6 and 10_7, read-write 10_8, value type CFBoolean). Note: You can only set or clear this property on directories; if you try to set this property on non-directory objects, the property is ignored. If the directory is a package for some other reason (extension type, etc), setting this property to false will have no effect. */ - -CF_EXPORT -const CFStringRef kCFURLIsSystemImmutableKey CF_AVAILABLE(10_6, 4_0); - /* True for system-immutable resources (Read-write, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLIsUserImmutableKey CF_AVAILABLE(10_6, 4_0); - /* True for user-immutable resources (Read-write, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLIsHiddenKey CF_AVAILABLE(10_6, 4_0); - /* True for resources normally not displayed to users (Read-write, value type CFBoolean). Note: If the resource is a hidden because its name starts with a period, setting this property to false will not change the property. */ - -CF_EXPORT -const CFStringRef kCFURLHasHiddenExtensionKey CF_AVAILABLE(10_6, 4_0); - /* True for resources whose filename extension is removed from the localized name property (Read-write, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLCreationDateKey CF_AVAILABLE(10_6, 4_0); - /* The date the resource was created (Read-write, value type CFDate) */ - -CF_EXPORT -const CFStringRef kCFURLContentAccessDateKey CF_AVAILABLE(10_6, 4_0); - /* The date the resource was last accessed (Read-only, value type CFDate) */ - -CF_EXPORT -const CFStringRef kCFURLContentModificationDateKey CF_AVAILABLE(10_6, 4_0); - /* The time the resource content was last modified (Read-write, value type CFDate) */ - -CF_EXPORT -const CFStringRef kCFURLAttributeModificationDateKey CF_AVAILABLE(10_6, 4_0); - /* The time the resource's attributes were last modified (Read-write, value type CFDate) */ - -CF_EXPORT -const CFStringRef kCFURLLinkCountKey CF_AVAILABLE(10_6, 4_0); - /* Number of hard links to the resource (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLParentDirectoryURLKey CF_AVAILABLE(10_6, 4_0); - /* The resource's parent directory, if any (Read-only, value type CFURL) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeURLKey CF_AVAILABLE(10_6, 4_0); - /* URL of the volume on which the resource is stored (Read-only, value type CFURL) */ - -CF_EXPORT -const CFStringRef kCFURLTypeIdentifierKey CF_AVAILABLE(10_6, 4_0); - /* Uniform type identifier (UTI) for the resource (Read-only, value type CFString) */ - -CF_EXPORT -const CFStringRef kCFURLLocalizedTypeDescriptionKey CF_AVAILABLE(10_6, 4_0); - /* User-visible type or "kind" description (Read-only, value type CFString) */ - -CF_EXPORT -const CFStringRef kCFURLLabelNumberKey CF_AVAILABLE(10_6, 4_0); - /* The label number assigned to the resource (Read-write, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLLabelColorKey CF_AVAILABLE(10_6, 4_0); - /* The color of the assigned label (Currently not implemented, value type CGColorRef, must link with Application Services) */ - -CF_EXPORT -const CFStringRef kCFURLLocalizedLabelKey CF_AVAILABLE(10_6, 4_0); - /* The user-visible label text (Read-only, value type CFString) */ - -CF_EXPORT -const CFStringRef kCFURLEffectiveIconKey CF_AVAILABLE(10_6, 4_0); - /* The icon normally displayed for the resource (Read-only, value type CGImageRef, must link with Application Services) */ - -CF_EXPORT -const CFStringRef kCFURLCustomIconKey CF_AVAILABLE(10_6, 4_0); - /* The custom icon assigned to the resource, if any (Currently not implemented, value type CGImageRef, must link with Application Services) */ - -CF_EXPORT -const CFStringRef kCFURLFileResourceIdentifierKey CF_AVAILABLE(10_7, 5_0); - /* An identifier which can be used to compare two file system objects for equality using CFEqual (i.e, two object identifiers are equal if they have the same file system path or if the paths are linked to same inode on the same file system). This identifier is not persistent across system restarts. (Read-only, value type CFType) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeIdentifierKey CF_AVAILABLE(10_7, 5_0); - /* An identifier that can be used to identify the volume the file system object is on. Other objects on the same volume will have the same volume identifier and can be compared using for equality using CFEqual. This identifier is not persistent across system restarts. (Read-only, value type CFType) */ - -CF_EXPORT -const CFStringRef kCFURLPreferredIOBlockSizeKey CF_AVAILABLE(10_7, 5_0); - /* The optimal block size when reading or writing this file's data, or NULL if not available. (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLIsReadableKey CF_AVAILABLE(10_7, 5_0); - /* true if this process (as determined by EUID) can read the resource. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLIsWritableKey CF_AVAILABLE(10_7, 5_0); - /* true if this process (as determined by EUID) can write to the resource. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLIsExecutableKey CF_AVAILABLE(10_7, 5_0); - /* true if this process (as determined by EUID) can execute a file resource or search a directory resource. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLFileSecurityKey CF_AVAILABLE(10_7, 5_0); - /* The file system object's security information encapsulated in a CFFileSecurity object. (Read-write, value type CFFileSecurity) */ - -CF_EXPORT -const CFStringRef kCFURLIsExcludedFromBackupKey CF_AVAILABLE(10_8, 5_1); - /* true if resource should be excluded from backups, false otherwise (Read-write, value type CFBoolean). This property is only useful for excluding cache and other application support files which are not needed in a backup. Some operations commonly made to user documents will cause this property to be reset to false and so this property should not be used on user documents. */ - -CF_EXPORT -const CFStringRef kCFURLTagNamesKey CF_AVAILABLE(10_9, NA); - /* The array of Tag names (Read-write, value type CFArray of CFString) */ - -CF_EXPORT -const CFStringRef kCFURLPathKey CF_AVAILABLE(10_8, 6_0); - /* the URL's path as a file system path (Read-only, value type CFString) */ - -CF_EXPORT -const CFStringRef kCFURLIsMountTriggerKey CF_AVAILABLE(10_7, 4_0); - /* true if this URL is a file system trigger directory. Traversing or opening a file system trigger will cause an attempt to mount a file system on the trigger directory. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLGenerationIdentifierKey CF_AVAILABLE(10_10, 8_0); - /* An opaque generation identifier which can be compared using CFEqual() to determine if the data in a document has been modified. For URLs which refer to the same file inode, the generation identifier will change when the data in the file's data fork is changed (changes to extended attributes or other file system metadata do not change the generation identifier). For URLs which refer to the same directory inode, the generation identifier will change when direct children of that directory are added, removed or renamed (changes to the data of the direct children of that directory will not change the generation identifier). The generation identifier is persistent across system restarts. The generation identifier is tied to a specific document on a specific volume and is not transferred when the document is copied to another volume. This property is not supported by all volumes. (Read-only, value type CFType) */ - -CF_EXPORT -const CFStringRef kCFURLDocumentIdentifierKey CF_AVAILABLE(10_10, 8_0); - /* The document identifier -- a value assigned by the kernel to a document (which can be either a file or directory) and is used to identify the document regardless of where it gets moved on a volume. The document identifier survives "safe save” operations; i.e it is sticky to the path it was assigned to (-replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error: is the preferred safe-save API). The document identifier is persistent across system restarts. The document identifier is not transferred when the file is copied. Document identifiers are only unique within a single volume. This property is not supported by all volumes. (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLAddedToDirectoryDateKey CF_AVAILABLE(10_10, 8_0); - /* The date the resource was created, or renamed into or within its parent directory. Note that inconsistent behavior may be observed when this attribute is requested on hard-linked items. This property is not supported by all volumes. (Read-only, value type CFDate) */ - -CF_EXPORT -const CFStringRef kCFURLQuarantinePropertiesKey CF_AVAILABLE(10_10, NA); - /* The quarantine properties as defined in LSQuarantine.h. To remove quarantine information from a file, pass kCFNull as the value when setting this property. (Read-write, value type CFDictionary) */ - -CF_EXPORT -const CFStringRef kCFURLFileResourceTypeKey CF_AVAILABLE(10_7, 5_0); - /* Returns the file system object type. (Read-only, value type CFString) */ - -/* The file system object type values returned for the kCFURLFileResourceTypeKey */ -CF_EXPORT -const CFStringRef kCFURLFileResourceTypeNamedPipe CF_AVAILABLE(10_7, 5_0); -CF_EXPORT -const CFStringRef kCFURLFileResourceTypeCharacterSpecial CF_AVAILABLE(10_7, 5_0); -CF_EXPORT -const CFStringRef kCFURLFileResourceTypeDirectory CF_AVAILABLE(10_7, 5_0); -CF_EXPORT -const CFStringRef kCFURLFileResourceTypeBlockSpecial CF_AVAILABLE(10_7, 5_0); -CF_EXPORT -const CFStringRef kCFURLFileResourceTypeRegular CF_AVAILABLE(10_7, 5_0); -CF_EXPORT -const CFStringRef kCFURLFileResourceTypeSymbolicLink CF_AVAILABLE(10_7, 5_0); -CF_EXPORT -const CFStringRef kCFURLFileResourceTypeSocket CF_AVAILABLE(10_7, 5_0); -CF_EXPORT -const CFStringRef kCFURLFileResourceTypeUnknown CF_AVAILABLE(10_7, 5_0); - -/* File Properties */ - -CF_EXPORT -const CFStringRef kCFURLFileSizeKey CF_AVAILABLE(10_6, 4_0); - /* Total file size in bytes (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLFileAllocatedSizeKey CF_AVAILABLE(10_6, 4_0); - /* Total size allocated on disk for the file in bytes (number of blocks times block size) (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLTotalFileSizeKey CF_AVAILABLE(10_7, 5_0); - /* Total displayable size of the file in bytes (this may include space used by metadata), or NULL if not available. (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLTotalFileAllocatedSizeKey CF_AVAILABLE(10_7, 5_0); - /* Total allocated size of the file in bytes (this may include space used by metadata), or NULL if not available. This can be less than the value returned by kCFURLTotalFileSizeKey if the resource is compressed. (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLIsAliasFileKey CF_AVAILABLE(10_6, 4_0); - /* true if the resource is a Finder alias file or a symlink, false otherwise ( Read-only, value type CFBooleanRef) */ - - -/* Volume Properties */ - -/* As a convenience, volume properties can be requested from any file system URL. The value returned will reflect the property value for the volume on which the resource is located. */ - -CF_EXPORT -const CFStringRef kCFURLVolumeLocalizedFormatDescriptionKey CF_AVAILABLE(10_6, 4_0); - /* The user-visible volume format (Read-only, value type CFString) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeTotalCapacityKey CF_AVAILABLE(10_6, 4_0); - /* Total volume capacity in bytes (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeAvailableCapacityKey CF_AVAILABLE(10_6, 4_0); - /* Total free space in bytes (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeResourceCountKey CF_AVAILABLE(10_6, 4_0); - /* Total number of resources on the volume (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsPersistentIDsKey CF_AVAILABLE(10_6, 4_0); - /* true if the volume format supports persistent object identifiers and can look up file system objects by their IDs (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsSymbolicLinksKey CF_AVAILABLE(10_6, 4_0); - /* true if the volume format supports symbolic links (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsHardLinksKey CF_AVAILABLE(10_6, 4_0); - /* true if the volume format supports hard links (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsJournalingKey CF_AVAILABLE(10_6, 4_0); - /* true if the volume format supports a journal used to speed recovery in case of unplanned restart (such as a power outage or crash). This does not necessarily mean the volume is actively using a journal. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeIsJournalingKey CF_AVAILABLE(10_6, 4_0); - /* true if the volume is currently using a journal for speedy recovery after an unplanned restart. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsSparseFilesKey CF_AVAILABLE(10_6, 4_0); - /* true if the volume format supports sparse files, that is, files which can have 'holes' that have never been written to, and thus do not consume space on disk. A sparse file may have an allocated size on disk that is less than its logical length. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsZeroRunsKey CF_AVAILABLE(10_6, 4_0); - /* For security reasons, parts of a file (runs) that have never been written to must appear to contain zeroes. true if the volume keeps track of allocated but unwritten runs of a file so that it can substitute zeroes without actually writing zeroes to the media. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsCaseSensitiveNamesKey CF_AVAILABLE(10_6, 4_0); - /* true if the volume format treats upper and lower case characters in file and directory names as different. Otherwise an upper case character is equivalent to a lower case character, and you can't have two names that differ solely in the case of the characters. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsCasePreservedNamesKey CF_AVAILABLE(10_6, 4_0); - /* true if the volume format preserves the case of file and directory names. Otherwise the volume may change the case of some characters (typically making them all upper or all lower case). (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsRootDirectoryDatesKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume supports reliable storage of times for the root directory. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsVolumeSizesKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume supports returning volume size values (kCFURLVolumeTotalCapacityKey and kCFURLVolumeAvailableCapacityKey). (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsRenamingKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume can be renamed. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsAdvisoryFileLockingKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume implements whole-file flock(2) style advisory locks, and the O_EXLOCK and O_SHLOCK flags of the open(2) call. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeSupportsExtendedSecurityKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume implements extended security (ACLs). (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeIsBrowsableKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume should be visible via the GUI (i.e., appear on the Desktop as a separate volume). (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeMaximumFileSizeKey CF_AVAILABLE(10_7, 5_0); - /* The largest file size (in bytes) supported by this file system, or NULL if this cannot be determined. (Read-only, value type CFNumber) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeIsEjectableKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume's media is ejectable from the drive mechanism under software control. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeIsRemovableKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume's media is removable from the drive mechanism. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeIsInternalKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume's device is connected to an internal bus, false if connected to an external bus, or NULL if not available. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeIsAutomountedKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume is automounted. Note: do not mistake this with the functionality provided by kCFURLVolumeSupportsBrowsingKey. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeIsLocalKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume is stored on a local device. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeIsReadOnlyKey CF_AVAILABLE(10_7, 5_0); - /* true if the volume is read-only. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeCreationDateKey CF_AVAILABLE(10_7, 5_0); - /* The volume's creation date, or NULL if this cannot be determined. (Read-only, value type CFDate) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeURLForRemountingKey CF_AVAILABLE(10_7, 5_0); - /* The CFURL needed to remount a network volume, or NULL if not available. (Read-only, value type CFURL) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeUUIDStringKey CF_AVAILABLE(10_7, 5_0); - /* The volume's persistent UUID as a string, or NULL if a persistent UUID is not available for the volume. (Read-only, value type CFString) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeNameKey CF_AVAILABLE(10_7, 5_0); - /* The name of the volume (Read-write, settable if kCFURLVolumeSupportsRenamingKey is true and permissions allow, value type CFString) */ - -CF_EXPORT -const CFStringRef kCFURLVolumeLocalizedNameKey CF_AVAILABLE(10_7, 5_0); - /* The user-presentable name of the volume (Read-only, value type CFString) */ - -/* UbiquitousItem Properties */ - -CF_EXPORT -const CFStringRef kCFURLIsUbiquitousItemKey CF_AVAILABLE(10_7, 5_0); - /* true if this item is synced to the cloud, false if it is only a local file. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemHasUnresolvedConflictsKey CF_AVAILABLE(10_7, 5_0); - /* true if this item has conflicts outstanding. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemIsDownloadedKey CF_DEPRECATED(10_7, 10_9, 5_0, 7_0, "Use kCFURLUbiquitousItemDownloadingStatusKey instead"); - /* Equivalent to NSURLUbiquitousItemDownloadingStatusKey == NSURLUbiquitousItemDownloadingStatusCurrent. Has never behaved as documented in earlier releases, hence deprecated. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemIsDownloadingKey CF_AVAILABLE(10_7, 5_0); - /* true if data is being downloaded for this item. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemIsUploadedKey CF_AVAILABLE(10_7, 5_0); - /* true if there is data present in the cloud for this item. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemIsUploadingKey CF_AVAILABLE(10_7, 5_0); - /* true if data is being uploaded for this item. (Read-only, value type CFBoolean) */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemPercentDownloadedKey CF_DEPRECATED(10_7, 10_8, 5_0, 6_0, "Use NSMetadataQuery and NSMetadataUbiquitousItemPercentDownloadedKey on NSMetadataItem instead"); - /* Use NSMetadataQuery and NSMetadataUbiquitousItemPercentDownloadedKey on NSMetadataItem instead */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemPercentUploadedKey CF_DEPRECATED(10_7, 10_8, 5_0, 6_0, "Use NSMetadataQuery and NSMetadataUbiquitousItemPercentUploadedKey on NSMetadataItem instead"); - /* Use NSMetadataQuery and NSMetadataUbiquitousItemPercentUploadedKey on NSMetadataItem instead */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemDownloadingStatusKey CF_AVAILABLE(10_9, 7_0); - /* Returns the download status of this item. (Read-only, value type CFString). Possible values below. */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemDownloadingErrorKey CF_AVAILABLE(10_9, 7_0); - /* returns the error when downloading the item from iCloud failed. See the NSUbiquitousFile section in FoundationErrors.h. (Read-only, value type CFError) */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemUploadingErrorKey CF_AVAILABLE(10_9, 7_0); - /* returns the error when uploading the item to iCloud failed. See the NSUbiquitousFile section in FoundationErrors.h. (Read-only, value type CFError) */ - -/* The values returned for kCFURLUbiquitousItemDownloadingStatusKey - */ -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemDownloadingStatusNotDownloaded CF_AVAILABLE(10_9, 7_0); - /* this item has not been downloaded yet. Use NSFileManager's startDownloadingUbiquitousItemAtURL:error: to download it */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemDownloadingStatusDownloaded CF_AVAILABLE(10_9, 7_0); - /* there is a local version of this item available. The most current version will get downloaded as soon as possible. */ - -CF_EXPORT -const CFStringRef kCFURLUbiquitousItemDownloadingStatusCurrent CF_AVAILABLE(10_9, 7_0); - /* there is a local version of this item and it is the most up-to-date version known to this device. */ - - -typedef CF_OPTIONS(CFOptionFlags, CFURLBookmarkCreationOptions) { - kCFURLBookmarkCreationMinimalBookmarkMask = ( 1UL << 9 ), // creates bookmark data with "less" information, which may be smaller but still be able to resolve in certain ways - kCFURLBookmarkCreationSuitableForBookmarkFile = ( 1UL << 10 ), // include the properties required by CFURLWriteBookmarkDataToFile() in the bookmark data created - kCFURLBookmarkCreationWithSecurityScope CF_ENUM_AVAILABLE(10_7, NA) = ( 1UL << 11 ), // Mac OS X 10.7.3 and later, include information in the bookmark data which allows the same sandboxed process to access the resource after being relaunched - kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess CF_ENUM_AVAILABLE(10_7, NA) = ( 1UL << 12 ), // Mac OS X 10.7.3 and later, if used with kCFURLBookmarkCreationWithSecurityScope, at resolution time only read access to the resource will be granted - - // deprecated - kCFURLBookmarkCreationPreferFileIDResolutionMask CF_ENUM_DEPRECATED(10_6, 10_9, 4_0, 7_0, "kCFURLBookmarkCreationPreferFileIDResolutionMask does nothing and has no effect on bookmark resolution" ) = ( 1UL << 8 ), -} CF_ENUM_AVAILABLE(10_6, 4_0); - -typedef CF_OPTIONS(CFOptionFlags, CFURLBookmarkResolutionOptions) { - kCFURLBookmarkResolutionWithoutUIMask = ( 1UL << 8 ), // don't perform any user interaction during bookmark resolution - kCFURLBookmarkResolutionWithoutMountingMask = ( 1UL << 9 ), // don't mount a volume during bookmark resolution - kCFURLBookmarkResolutionWithSecurityScope CF_ENUM_AVAILABLE(10_7, NA) = ( 1UL << 10 ), // Mac OS X 10.7.3 and later, use the secure information included at creation time to provide the ability to access the resource in a sandboxed process. - - kCFBookmarkResolutionWithoutUIMask = kCFURLBookmarkResolutionWithoutUIMask, - kCFBookmarkResolutionWithoutMountingMask = kCFURLBookmarkResolutionWithoutMountingMask, -} CF_ENUM_AVAILABLE(10_6, 4_0); - -typedef CFOptionFlags CFURLBookmarkFileCreationOptions; - -CF_IMPLICIT_BRIDGING_DISABLED - -/* Returns bookmark data for the URL, created with specified options and resource properties. If this function returns NULL, the optional error is populated. - */ -CF_EXPORT -CFDataRef CFURLCreateBookmarkData ( CFAllocatorRef allocator, CFURLRef url, CFURLBookmarkCreationOptions options, CFArrayRef resourcePropertiesToInclude, CFURLRef relativeToURL, CFErrorRef* error ) CF_AVAILABLE(10_6, 4_0); - -/* Return a URL that refers to a location specified by resolving bookmark data. If this function returns NULL, the optional error is populated. - */ -CF_EXPORT -CFURLRef CFURLCreateByResolvingBookmarkData ( CFAllocatorRef allocator, CFDataRef bookmark, CFURLBookmarkResolutionOptions options, CFURLRef relativeToURL, CFArrayRef resourcePropertiesToInclude, Boolean* isStale, CFErrorRef* error ) CF_AVAILABLE(10_6, 4_0); - -/* Returns the resource propertyies identified by a specified array of keys contained in specified bookmark data. If the result dictionary does not contain a resource value for one or more of the requested resource keys, it means those resource properties are not available in the bookmark data. - */ -CF_EXPORT -CFDictionaryRef CFURLCreateResourcePropertiesForKeysFromBookmarkData ( CFAllocatorRef allocator, CFArrayRef resourcePropertiesToReturn, CFDataRef bookmark ) CF_AVAILABLE(10_6, 4_0); - -/* Returns the resource property identified by a given resource key contained in specified bookmark data. If this function returns NULL, it means the resource property is not available in the bookmark data. - */ -CF_EXPORT -CFTypeRef CFURLCreateResourcePropertyForKeyFromBookmarkData( CFAllocatorRef allocator, CFStringRef resourcePropertyKey, CFDataRef bookmark ) CF_AVAILABLE(10_6, 4_0); - -/* Returns bookmark data derived from an alias file referred to by fileURL. If fileURL refers to an alias file created prior to OS X v10.6 that contains Alias Manager information but no bookmark data, this method synthesizes bookmark data for the file. If this method returns NULL, the optional error is populated. - */ -CF_EXPORT -CFDataRef CFURLCreateBookmarkDataFromFile(CFAllocatorRef allocator, CFURLRef fileURL, CFErrorRef *errorRef ) CF_AVAILABLE(10_6, 5_0); - -/* Creates an alias file on disk at a specified location with specified bookmark data. The bookmark data must have been created with the kCFURLBookmarkCreationSuitableForBookmarkFile option. fileURL must either refer to an existing file (which will be overwritten), or to location in an existing directory. If this method returns FALSE, the optional error is populated. - */ -CF_EXPORT -Boolean CFURLWriteBookmarkDataToFile( CFDataRef bookmarkRef, CFURLRef fileURL, CFURLBookmarkFileCreationOptions options, CFErrorRef *errorRef ) CF_AVAILABLE(10_6, 5_0); - -/* Returns bookmark data derived from an alias record. - */ -CF_EXPORT -CFDataRef CFURLCreateBookmarkDataFromAliasRecord ( CFAllocatorRef allocatorRef, CFDataRef aliasRecordDataRef ) CF_AVAILABLE_MAC(10_6); - -CF_IMPLICIT_BRIDGING_ENABLED - -/* Given a CFURLRef created by resolving a bookmark data created with security scope, make the resource referenced by the url accessible to the process. When access to this resource is no longer needed the client must call CFURLStopAccessingSecurityScopedResource(). Each call to CFURLStartAccessingSecurityScopedResource() must be balanced with a call to CFURLStopAccessingSecurityScopedResource() (Note: this is not reference counted). - */ -CF_EXPORT -Boolean CFURLStartAccessingSecurityScopedResource(CFURLRef url) CF_AVAILABLE(10_7, 8_0); // On OSX, available in MacOS X 10.7.3 and later - -/* Revokes the access granted to the url by a prior successful call to CFURLStartAccessingSecurityScopedResource(). - */ -CF_EXPORT -void CFURLStopAccessingSecurityScopedResource(CFURLRef url) CF_AVAILABLE(10_7, 8_0); // On OSX, available in MacOS X 10.7.3 and later - -#endif /* TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE */ - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFURL__ */ - diff --git a/CFURL.h b/CFURL.h new file mode 120000 index 0000000..2958b89 --- /dev/null +++ b/CFURL.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFURL.h \ No newline at end of file diff --git a/CFURL.inc.h b/CFURL.inc.h deleted file mode 100644 index b373493..0000000 --- a/CFURL.inc.h +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFURL.inc.h - Copyright (c) 2012-2014, Apple Inc. All rights reserved. - Responsibility: Jim Luther/Chris Linn -*/ - - -/* - - What's this file for? - - CFURL's URL string parser needs to be able to parse either an array of char or an array of UniChar. - - The code in CFURL.c used to use this macro "#define STRING_CHAR(x) (useCString ? cstring[(x)] : ustring[(x)])" to determine which array to get a character from for every character looked at in the URL string. That macro added one or more compare and branch instructins to the parser's execution for *every* character in the URL string. Those extra compares and branches added up to 10% of the time (for long URL strings) it takes to create a URL object. - - To ensure the exact same parser code is run over a char or a UniChar string, the source code was move to this .h file and is included multiple times by CFURL.c as needed. "STRING_CHAR(x)" was replaced by "characterArray[x]", and characterArray is defined as either an "const char *" or a "const UniChar *" for the two sets of function headers that are either parsing an array of char or an array of UniChar. - - Any changes made to the parser are made in this file so that both char and the UniChar strings are parsed exactly the same way. - - */ - -/* - static void _parseComponentsCString(CFAllocatorRef alloc, CFURLRef baseURL, CFIndex cfStringLength, const char *characterArray, UInt32 *theFlags, CFRange *packedRanges, uint8_t *numberOfRanges) - or - static void _parseComponentsUString(CFAllocatorRef alloc, CFURLRef baseURL, CFIndex cfStringLength, const UniChar *characterArray, UInt32 *theFlags, CFRange *packedRanges, uint8_t *numberOfRanges) - */ -#ifdef CFURL_INCLUDE_PARSE_COMPONENTS // defined when we want this block of code included -{ - /* index gives the URL part involved; to calculate the correct range index, use the number of the bit of the equivalent flag (i.e. the host flag is HAS_HOST, which is 0x8. so the range index for the host is 3.) Note that this is true in this function ONLY, since the ranges stored in (*range) are actually packed, skipping those URL components that don't exist. This is why the indices are hard-coded in this function. */ - enum { - scheme_index = 0, - user_index = 1, - password_index = 2, - host_index = 3, - port_index = 4, - path_index = 5, - parameters_index = 6, - query_index = 7, - fragment_index = 8, - }; - CFRange unpackedRanges[MAX_COMPONENTS]; - - CFIndex idx, base_idx = 0; - CFIndex string_length; - UInt32 flags = *theFlags; - Boolean isCompliant; - uint8_t numRanges = 0; - - string_length = cfStringLength; - - // Algorithm is as described in RFC 1808 - // 1: parse the fragment; remainder after left-most "#" is fragment - for (idx = base_idx; idx < string_length; idx++) { - if ('#' == characterArray[idx]) { - flags |= HAS_FRAGMENT; - unpackedRanges[fragment_index].location = idx + 1; - unpackedRanges[fragment_index].length = string_length - (idx + 1); - numRanges ++; - string_length = idx; // remove fragment from parse string - break; - } - } - // 2: parse the scheme - for (idx = base_idx; idx < string_length; idx++) { - UniChar ch = characterArray[idx]; - if (':' == ch) { - flags |= HAS_SCHEME; - unpackedRanges[scheme_index].location = base_idx; - unpackedRanges[scheme_index].length = idx; - numRanges ++; - base_idx = idx + 1; - // optimization for ftp urls - if (idx == 3 && characterArray[0] == 'f' && characterArray[1] == 't' && characterArray[2] == 'p') { - _setSchemeTypeInFlags(&flags, kHasFtpScheme); - } - else if (idx == 4) { - // optimization for http urls - if (characterArray[0] == 'h' && characterArray[1] == 't' && characterArray[2] == 't' && characterArray[3] == 'p') { - _setSchemeTypeInFlags(&flags, kHasHttpScheme); - } - // optimization for file urls - if (characterArray[0] == 'f' && characterArray[1] == 'i' && characterArray[2] == 'l' && characterArray[3] == 'e') { - _setSchemeTypeInFlags(&flags, kHasFileScheme); - } - // optimization for data urls - if (characterArray[0] == 'd' && characterArray[1] == 'a' && characterArray[2] == 't' && characterArray[3] == 'a') { - _setSchemeTypeInFlags(&flags, kHasDataScheme); - } - } - // optimization for https urls - else if (idx == 5 && characterArray[0] == 'h' && characterArray[1] == 't' && characterArray[2] == 't' && characterArray[3] == 'p' && characterArray[3] == 's') { - _setSchemeTypeInFlags(&flags, kHasHttpsScheme); - } - break; - } else if (!scheme_valid(ch)) { - break; // invalid scheme character -- no scheme - } - } - - // Make sure we have an RFC-1808 compliant URL - that's either something without a scheme, or scheme:/(stuff) or scheme://(stuff) - // Strictly speaking, RFC 1808 & 2396 bar "scheme:" (with nothing following the colon); however, common usage - // expects this to be treated identically to "scheme://" - REW, 12/08/03 - if (!(flags & HAS_SCHEME)) { - isCompliant = true; - } else if (base_idx == string_length) { - isCompliant = false; - } else if (characterArray[base_idx] != '/') { - isCompliant = false; - } else { - isCompliant = true; - } - - if (!isCompliant) { - // Clear the fragment flag if it's been set - if (flags & HAS_FRAGMENT) { - flags &= (~HAS_FRAGMENT); - string_length = cfStringLength; - } - (*theFlags) = flags; - packedRanges[scheme_index].location = unpackedRanges[scheme_index].location; - packedRanges[scheme_index].length = unpackedRanges[scheme_index].length; - *numberOfRanges = 1; - } - else { - // URL is 1808-compliant - flags |= IS_DECOMPOSABLE; - - // 3: parse the network location and login - if (2 <= (string_length - base_idx) && '/' == characterArray[base_idx] && '/' == characterArray[base_idx+1]) { - CFIndex base = 2 + base_idx, extent; - for (idx = base; idx < string_length; idx++) { - if ('/' == characterArray[idx] || '?' == characterArray[idx]) { - break; - } - } - extent = idx; - - // net_loc parts extend from base to extent (but not including), which might be to end of string - // net location is ":@:" - if (extent != base) { - for (idx = base; idx < extent; idx++) { - if ('@' == characterArray[idx]) { // there is a user - CFIndex idx2; - flags |= HAS_USER; - numRanges ++; - unpackedRanges[user_index].location = base; // base of the user - for (idx2 = base; idx2 < idx; idx2++) { - if (':' == characterArray[idx2]) { // found a password separator - flags |= HAS_PASSWORD; - numRanges ++; - unpackedRanges[password_index].location = idx2+1; // base of the password - unpackedRanges[password_index].length = idx-(idx2+1); // password extent - unpackedRanges[user_index].length = idx2 - base; // user extent - break; - } - } - if (!(flags & HAS_PASSWORD)) { - // user extends to the '@' - unpackedRanges[user_index].length = idx - base; // user extent - } - base = idx + 1; - break; - } - } - flags |= HAS_HOST; - numRanges ++; - unpackedRanges[host_index].location = base; // base of host - - // base has been advanced past the user and password if they existed - for (idx = base; idx < extent; idx++) { - // IPV6 support (RFC 2732) DCJ June/10/2002 - if ('[' == characterArray[idx]) { // starting IPV6 explicit address - // Find the ']' terminator of the IPv6 address, leave idx pointing to ']' or end - for ( ; idx < extent; ++ idx ) { - if ( ']' == characterArray[idx]) { - flags |= IS_IPV6_ENCODED; - break; - } - } - } - // there is a port if we see a colon. Only the last one is the port, though. - else if ( ':' == characterArray[idx]) { - flags |= HAS_PORT; - numRanges ++; - unpackedRanges[port_index].location = idx+1; // base of port - unpackedRanges[port_index].length = extent - (idx+1); // port extent - unpackedRanges[host_index].length = idx - base; // host extent - break; - } - } - if (!(flags & HAS_PORT)) { - unpackedRanges[host_index].length = extent - base; // host extent - } - } - base_idx = extent; - } - - // 4: parse the query; remainder after left-most "?" is query - for (idx = base_idx; idx < string_length; idx++) { - if ('?' == characterArray[idx]) { - flags |= HAS_QUERY; - numRanges ++; - unpackedRanges[query_index].location = idx + 1; - unpackedRanges[query_index].length = string_length - (idx+1); - string_length = idx; // remove query from parse string - break; - } - } - - // 5: parse the parameters; remainder after left-most ";" is parameters - for (idx = base_idx; idx < string_length; idx++) { - if (';' == characterArray[idx]) { - flags |= HAS_PARAMETERS; - numRanges ++; - unpackedRanges[parameters_index].location = idx + 1; - unpackedRanges[parameters_index].length = string_length - (idx+1); - string_length = idx; // remove parameters from parse string - break; - } - } - - // 6: parse the path; it's whatever's left between string_length & base_idx - if (string_length - base_idx != 0 || (flags & NET_LOCATION_MASK)) - { - // If we have a net location, we are 1808-compliant, and an empty path substring implies a path of "/" - UniChar ch; - Boolean isDir; - CFRange pathRg; - flags |= HAS_PATH; - numRanges ++; - pathRg.location = base_idx; - pathRg.length = string_length - base_idx; - unpackedRanges[path_index] = pathRg; - - if (pathRg.length > 0) { - Boolean sawPercent = FALSE; - for (idx = pathRg.location; idx < string_length; idx++) { - if ('%' == characterArray[idx]) { - sawPercent = TRUE; - break; - } - } -#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI - if (pathRg.length > 6 && characterArray[pathRg.location] == '/' && characterArray[pathRg.location + 1] == '.' && characterArray[pathRg.location + 2] == 'f' && characterArray[pathRg.location + 3] == 'i' && characterArray[pathRg.location + 4] == 'l' && characterArray[pathRg.location + 5] == 'e' && characterArray[pathRg.location + 6] == '/') { - flags |= PATH_HAS_FILE_ID; - } else if (!sawPercent) { - flags |= POSIX_AND_URL_PATHS_MATCH; - } -#elif DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_WINDOWS - if (!sawPercent) { - flags |= POSIX_AND_URL_PATHS_MATCH; - } -#endif - - ch = characterArray[pathRg.location + pathRg.length - 1]; - if (ch == '/') { - isDir = true; - } else if (ch == '.') { - if (pathRg.length == 1) { - isDir = true; - } else { - ch = characterArray[pathRg.location + pathRg.length - 2]; - if (ch == '/') { - isDir = true; - } else if (ch != '.') { - isDir = false; - } else if (pathRg.length == 2) { - isDir = true; - } else { - isDir = (characterArray[pathRg.location + pathRg.length - 3] == '/'); - } - } - } else { - isDir = false; - } - } else { - isDir = (baseURL != NULL) ? CFURLHasDirectoryPath(baseURL) : false; - } - if (isDir) { - flags |= IS_DIRECTORY; - } - } - - (*theFlags) = flags; - *numberOfRanges = numRanges; - numRanges = 0; - for (idx = 0, flags = 1; flags != (1<<9); flags = (flags<<1), idx ++) { - if ((*theFlags) & flags) { - packedRanges[numRanges] = unpackedRanges[idx]; - numRanges ++; - } - } - } -} -#endif // CFURL_INCLUDE_PARSE_COMPONENTS - -/* - static Boolean scanCharactersCString(CFAllocatorRef alloc, CFMutableStringRef *escapedString, UInt32 *flags, const char *characterArray, Boolean useCString, CFIndex base, CFIndex end, CFIndex *mark, UInt32 componentFlag, CFStringEncoding encoding) - static Boolean scanCharactersUString(CFAllocatorRef alloc, CFMutableStringRef *escapedString, UInt32 *flags, const UniChar *characterArray, Boolean useCString, CFIndex base, CFIndex end, CFIndex *mark, UInt32 componentFlag, CFStringEncoding encoding) - */ -#ifdef CFURL_INCLUDE_SCAN_CHARACTERS // defined when we want this block of code included -{ - CFIndex idx; - Boolean sawIllegalChar = false; - for (idx = base; idx < end; idx ++) { - Boolean shouldEscape; - UniChar ch = characterArray[idx]; - if (isURLLegalCharacter(ch)) { - if ((componentFlag == HAS_USER || componentFlag == HAS_PASSWORD) && (ch == '/' || ch == '?' || ch == '@')) { - shouldEscape = true; - } else { - shouldEscape = false; - } - } else if (ch == '%' && idx + 2 < end && isHexDigit(characterArray[idx + 1]) && isHexDigit(characterArray[idx+2])) { - shouldEscape = false; - } else if (componentFlag == HAS_HOST && ((idx == base && ch == '[') || (idx == end-1 && ch == ']'))) { - shouldEscape = false; - } else { - shouldEscape = true; - } - if (shouldEscape) { - sawIllegalChar = true; - if (componentFlag && flags) { - *flags |= componentFlag; - } - if (!*escapedString) { - *escapedString = CFStringCreateMutable(alloc, 0); - } - if (useCString) { - CFStringRef tempString = CFStringCreateWithBytes(alloc, (uint8_t *)&(characterArray[*mark]), idx - *mark, kCFStringEncodingISOLatin1, false); - CFStringAppend(*escapedString, tempString); - CFRelease(tempString); - } else { - CFStringAppendCharacters(*escapedString, (const UniChar *)&(characterArray[*mark]), idx - *mark); - } - *mark = idx + 1; - _appendPercentEscapesForCharacter(ch, encoding, *escapedString); // This can never fail because anURL->_string was constructed from the encoding passed in - } - } - return sawIllegalChar; -} -#endif // CFURL_INCLUDE_SCAN_CHARACTERS diff --git a/CFURL.inc.h b/CFURL.inc.h new file mode 120000 index 0000000..e952370 --- /dev/null +++ b/CFURL.inc.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFURL.inc.h \ No newline at end of file diff --git a/CFURLAccess.h b/CFURLAccess.h deleted file mode 100644 index 6986e39..0000000 --- a/CFURLAccess.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFURLAccess.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. - - 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. -*/ - -#if !defined(__COREFOUNDATION_CFURLACCESS__) -#define __COREFOUNDATION_CFURLACCESS__ 1 - -#include -#include -#include -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - - - -/* Attempts to read the data and properties for the given URL. If -only interested in one of the resourceData and properties, pass NULL -for the other. If properties is non-NULL and desiredProperties is -NULL, then all properties are fetched. Returns success or failure; -note that as much work as possible is done even if false is returned. -So for instance if one property is not available, the others are -fetched anyway. errorCode is set to 0 on success, and some other -value on failure. If non-NULL, it is the caller 's responsibility -to release resourceData and properties. - - Apple reserves for its use all negative error code values; these -values represent errors common to any scheme. Scheme-specific error -codes should be positive, non-zero, and should be used only if one of -the predefined Apple error codes does not apply. Error codes should -be publicized and documented with the scheme-specific properties. - -NOTE: When asking for the resource data, this call will allocate the entire -resource in memory. This can be very expensive, depending on the size of the -resource (file). Please use CFStream or other techniques if you are downloading -large files. - -*/ -/* Deprecated -- see top of this file for suggested replacement classes */ -CF_EXPORT -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."); - -/* Attempts to write the given data and properties to the given URL. -If dataToWrite is NULL, only properties are written out (use -CFURLDestroyResource() to delete a resource). Properties not present -in propertiesToWrite are left unchanged, hence if propertiesToWrite -is NULL or empty, the URL's properties are not changed at all. -Returns success or failure; errorCode is set as for -CFURLCreateDataAndPropertiesFromResource(), above. -*/ -/* Deprecated -- see top of this file for suggested replacement classes */ -CF_EXPORT -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."); - -/* Destroys the resource indicated by url. -Returns success or failure; errorCode set as above. -*/ -/* Deprecated -- see top of this file for suggested replacement classes */ -CF_EXPORT -Boolean CFURLDestroyResource(CFURLRef url, SInt32 *errorCode) CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLGetFileSystemRepresentation and removefile(3) instead."); - -/* Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource(). -Returns NULL on error and sets errorCode accordingly. -*/ -/* Deprecated -- see top of this file for suggested replacement classes */ -CF_EXPORT -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."); - - -/* Common error codes (returned only by the older APIs that predate CFError) */ -typedef CF_ENUM(CFIndex, CFURLError) { - kCFURLUnknownError = -10L, - kCFURLUnknownSchemeError = -11L, - kCFURLResourceNotFoundError = -12L, - kCFURLResourceAccessViolationError = -13L, - kCFURLRemoteHostUnavailableError = -14L, - kCFURLImproperArgumentsError = -15L, - kCFURLUnknownPropertyKeyError = -16L, - kCFURLPropertyKeyUnavailableError = -17L, - kCFURLTimeoutError = -18L -} CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0); - -/* Older property keys */ - -CF_EXPORT -const CFStringRef kCFURLFileExists CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLResourceIsReachable instead."); -CF_EXPORT -const CFStringRef kCFURLFileDirectoryContents CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use the CFURLEnumerator API instead."); -CF_EXPORT -const CFStringRef kCFURLFileLength CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLFileSizeKey instead."); -CF_EXPORT -const CFStringRef kCFURLFileLastModificationTime CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLContentModificationDateKey instead."); -CF_EXPORT -const CFStringRef kCFURLFilePOSIXMode CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLFileSecurityKey and then the CFFileSecurity API instead."); -CF_EXPORT -const CFStringRef kCFURLFileOwnerID CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLFileSecurityKey and then the CFFileSecurity API instead."); -CF_EXPORT -const CFStringRef kCFURLHTTPStatusCode CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use NSHTTPURLResponse methods instead."); -CF_EXPORT -const CFStringRef kCFURLHTTPStatusLine CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use NSHTTPURLResponse methods instead."); - -/* The value of kCFURLFileExists is a CFBoolean */ -/* The value of kCFURLFileDirectoryContents is a CFArray containing CFURLs. An empty array means the directory exists, but is empty */ -/* The value of kCFURLFileLength is a CFNumber giving the file's length in bytes */ -/* The value of kCFURLFileLastModificationTime is a CFDate */ -/* The value of kCFURLFilePOSIXMode is a CFNumber as given in stat.h */ -/* The value of kCFURLFileOwnerID is a CFNumber representing the owner's uid */ - -/* 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 */ -/* The value of kCFURLHTTPStatusCode is a CFNumber */ -/* The value of kCFURLHTTPStatusLine is a CFString */ - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFURLACCESS__ */ - diff --git a/CFURLAccess.h b/CFURLAccess.h new file mode 120000 index 0000000..f81616d --- /dev/null +++ b/CFURLAccess.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFURLAccess.h \ No newline at end of file diff --git a/CFURLEnumerator.h b/CFURLEnumerator.h deleted file mode 100644 index dfba61a..0000000 --- a/CFURLEnumerator.h +++ /dev/null @@ -1,42 +0,0 @@ -#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION -#if !defined(__COREFOUNDATION_CFURLENUMERATOR__) -#define __COREFOUNDATION_CFURLENUMERATOR__ 1 - -#include -#include -#include -#include - -CF_EXTERN_C_BEGIN - -typedef const struct __CFURLEnumerator *CFURLEnumeratorRef; - -typedef CF_OPTIONS(CFOptionFlags, CFURLEnumeratorOptions) { - kCFURLEnumeratorDefaultBehavior = 0, - kCFURLEnumeratorDescendRecursively = 1UL << 0, - kCFURLEnumeratorSkipInvisibles = 1UL << 1, - kCFURLEnumeratorGenerateFileReferenceURLs = 1UL << 2, - kCFURLEnumeratorSkipPackageContents = 1UL << 3, - kCFURLEnumeratorIncludeDirectoriesPreOrder = 1UL << 4, - kCFURLEnumeratorIncludeDirectoriesPostOrder = 1UL << 5, -}; - -typedef CF_ENUM(CFIndex, CFURLEnumeratorResult) { - kCFURLEnumeratorSuccess = 1, - kCFURLEnumeratorEnd = 2, - kCFURLEnumeratorError = 3, - kCFURLEnumeratorDirectoryPostOrderSuccess = 4, -}; - -CF_EXPORT CFTypeID CFURLEnumeratorGetTypeID(void); -CF_EXPORT CFURLEnumeratorRef CFURLEnumeratorCreateForDirectoryURL(CFAllocatorRef alloc, CFURLRef directoryURL, CFURLEnumeratorOptions option, CFArrayRef propertyKeys); -CF_EXPORT CFURLEnumeratorRef CFURLEnumeratorCreateForMountedVolumes(CFAllocatorRef alloc, CFURLEnumeratorOptions option, CFArrayRef propertyKeys); -CF_EXPORT CFURLEnumeratorResult CFURLEnumeratorGetNextURL(CFURLEnumeratorRef enumerator, CFURLRef *url, CFErrorRef *error); -CF_EXPORT void CFURLEnumeratorSkipDescendents(CFURLEnumeratorRef enumerator); -CF_EXPORT CFIndex CFURLEnumeratorGetDescendentLevel(CFURLEnumeratorRef enumerator); -CF_EXPORT Boolean CFURLEnumeratorGetSourceDidChange(CFURLEnumeratorRef enumerator); - -CF_EXTERN_C_END - -#endif -#endif diff --git a/CFURLEnumerator.h b/CFURLEnumerator.h new file mode 120000 index 0000000..d16ff9c --- /dev/null +++ b/CFURLEnumerator.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFURLEnumerator.h \ No newline at end of file diff --git a/CFURLPriv.h b/CFURLPriv.h deleted file mode 100644 index b90699a..0000000 --- a/CFURLPriv.h +++ /dev/null @@ -1,692 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFURLPriv.h - Copyright (c) 2008-2014, Apple Inc. All rights reserved. - Responsibility: Jim Luther/Chris Linn - */ - -#if !defined(__COREFOUNDATION_CFURLPRIV__) -#define __COREFOUNDATION_CFURLPRIV__ 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if TARGET_OS_MAC -#include -#endif - -CF_EXTERN_C_BEGIN - -// The kCFURLxxxxError enums are error codes in the Cocoa error domain and they mirror the exact same codes in (i.e. kCFURLReadNoPermissionError = NSFileReadNoPermissionError = 257). They were added to CFURLPriv.h so that CarbonCore and later CoreServicesInternal could return these error codes in the Cocoa error domain. If your code links with Foundation, you should use the codes in , not these codes. -enum { - // Resource I/O related errors, with kCFErrorURLKey containing URL - kCFURLNoSuchResourceError = 4, // Attempt to do a file system operation on a non-existent file - kCFURLResourceLockingError = 255, // Couldn't get a lock on file - kCFURLReadUnknownError = 256, // Read error (reason unknown) - kCFURLReadNoPermissionError = 257, // Read error (permission problem) - kCFURLReadInvalidResourceNameError = 258, // Read error (invalid file name) - kCFURLReadCorruptResourceError = 259, // Read error (file corrupt, bad format, etc) - kCFURLReadNoSuchResourceError = 260, // Read error (no such file) - kCFURLReadInapplicableStringEncodingError = 261, // Read error (string encoding not applicable) also kCFStringEncodingErrorKey - kCFURLReadUnsupportedSchemeError = 262, // Read error (unsupported URL scheme) - kCFURLReadTooLargeError = 263, // Read error (file too large) - kCFURLReadUnknownStringEncodingError = 264, // Read error (string encoding of file contents could not be determined) - kCFURLWriteUnknownError = 512, // Write error (reason unknown) - kCFURLWriteNoPermissionError = 513, // Write error (permission problem) - kCFURLWriteInvalidResourceNameError = 514, // Write error (invalid file name) - kCFURLWriteInapplicableStringEncodingError = 517, // Write error (string encoding not applicable) also kCFStringEncodingErrorKey - kCFURLWriteUnsupportedSchemeError = 518, // Write error (unsupported URL scheme) - kCFURLWriteOutOfSpaceError = 640, // Write error (out of storage space) - kCFURLWriteVolumeReadOnlyError = 642, // Write error (readonly volume) -} CF_ENUM_AVAILABLE(10_5, 2_0); - - -/* - Private File System Property Keys -*/ -CF_EXPORT const CFStringRef _kCFURLPathKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLPathKey or NSURLPathKey public property keys */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIDKey CF_AVAILABLE(10_6, 4_0); - /* Volume ID (CFNumber) */ - -CF_EXPORT const CFStringRef _kCFURLInodeNumberKey CF_AVAILABLE(10_6, 4_0); - /* 64-bit inode number (the inode number from the file system) (CFNumber) */ - -CF_EXPORT const CFStringRef _kCFURLFileIDKey CF_AVAILABLE(10_6, 4_0); - /* 64-bit file ID (for tracking a file by ID. This may or may not be the inode number) (CFNumber) */ - -CF_EXPORT const CFStringRef _kCFURLParentDirectoryIDKey CF_AVAILABLE(10_6, 4_0); - /* 64-bit file ID (for tracking a parent directory by ID. This may or may not be the inode number) (CFNumber) */ - -CF_EXPORT const CFStringRef _kCFURLDistinctLocalizedNameKey CF_AVAILABLE(10_6, 4_0); - /* The localized name, if it is distinct from the real name. Otherwise, NULL (CFString) */ - -CF_EXPORT const CFStringRef _kCFURLNameExtensionKey CF_AVAILABLE(10_6, 4_0); - /* The name extension (CFString) */ - -CF_EXPORT const CFStringRef _kCFURLFinderInfoKey CF_AVAILABLE(10_6, 4_0); - /* A 16-byte Finder Info structure immediately followed by a 16-byte Extended Finder Info structure (CFData) */ - -CF_EXPORT const CFStringRef _kCFURLIsCompressedKey CF_AVAILABLE(10_6, 4_0); - /* True if resource's data is transparently compressed by the system on its storage device (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLIsApplicationKey CF_AVAILABLE(10_6, 4_0); - /* True if resource is an application (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLCanSetHiddenExtensionKey CF_AVAILABLE(10_6, 4_0); - /* True if the filename extension can be hidden or unhidden (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLIsReadableKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLIsReadableKey or NSURLIsReadableKey public property keys */ -/* never implemented and scheduled for removal in 10.10/8.0 */CF_EXPORT const CFStringRef _kCFURLUserCanReadKey CF_DEPRECATED(10_0, 10_6, 2_0, 4_0); - -CF_EXPORT const CFStringRef _kCFURLIsWriteableKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLIsWritableKey or NSURLIsWritableKey public property keys */ -/* never implemented and scheduled for removal in 10.10/8.0 */CF_EXPORT const CFStringRef _kCFURLUserCanWriteKey CF_DEPRECATED(10_0, 10_6, 2_0, 4_0); - -CF_EXPORT const CFStringRef _kCFURLIsExecutableKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLIsExecutableKey or NSURLIsExecutableKey public property keys */ -/* never implemented and scheduled for removal in 10.10/8.0 */CF_EXPORT const CFStringRef _kCFURLUserCanExecuteKey CF_DEPRECATED(10_0, 10_6, 2_0, 4_0); - -CF_EXPORT const CFStringRef _kCFURLParentDirectoryIsVolumeRootKey CF_AVAILABLE(10_6, 4_0); - /* True if the parent directory is the root of a volume (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLFileSecurityKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLFileSecurityKey or NSURLFileSecurityKey public property keys */ - -CF_EXPORT const CFStringRef _kCFURLFileSizeOfResourceForkKey CF_AVAILABLE(10_6, 4_0); - /* Size in bytes of the resource fork (CFNumber) */ - -CF_EXPORT const CFStringRef _kCFURLFileAllocatedSizeOfResourceForkKey CF_AVAILABLE(10_6, 4_0); - /* Size in bytes of the blocks allocated for the resource fork (CFNumber) */ - -CF_EXPORT const CFStringRef _kCFURLEffectiveIconImageDataKey CF_AVAILABLE(10_6, 4_0); - /* Icon image data, i.e. raw pixel data (CFData) */ - -CF_EXPORT const CFStringRef _kCFURLTypeBindingKey CF_AVAILABLE(10_10, 8_0); - /* Type binding for icon (Read-only, value type CFData) */ - -CF_EXPORT const CFStringRef _kCFURLCustomIconImageDataKey CF_AVAILABLE(10_6, 4_0); - /* Icon image data of the item's custom icon, if any (CFData) */ - -CF_EXPORT const CFStringRef _kCFURLEffectiveIconFlattenedReferenceDataKey CF_AVAILABLE(10_6, 4_0); - /* Icon flattened reference, suitable for cheaply sharing the effective icon reference across processess (CFData) */ - -CF_EXPORT const CFStringRef _kCFURLBundleIdentifierKey CF_AVAILABLE(10_6, 4_0); - /* If resource is a bundle, the bundle identifier (CFString) */ - -CF_EXPORT const CFStringRef _kCFURLVersionKey CF_AVAILABLE(10_6, 4_0); - /* If resource is a bundle, the bundle version (CFBundleVersion) as a string (CFString) */ - -CF_EXPORT const CFStringRef _kCFURLShortVersionStringKey CF_AVAILABLE(10_6, 4_0); - /* If resource is a bundle, the bundle short version (CFBundleShortVersionString) as a string (CFString) */ - -CF_EXPORT const CFStringRef _kCFURLOwnerIDKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal later in 10.9/7.0 since it is unused - Use the kCFURLFileSecurityKey or NSURLFileSecurityKey public property keys and CFFileSecurityGetOwner() */ - -CF_EXPORT const CFStringRef _kCFURLGroupIDKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal later in 10.9/7.0 since it is unused - Use the kCFURLFileSecurityKey or NSURLFileSecurityKey public property keys and CFFileSecurityGetGroup() */ - -CF_EXPORT const CFStringRef _kCFURLStatModeKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal later in 10.9/7.0 since it is unused - Use the kCFURLFileSecurityKey or NSURLFileSecurityKey public property keys and CFFileSecurityGetMode() */ - -CF_EXPORT const CFStringRef _kCFURLLocalizedNameDictionaryKey CF_AVAILABLE(10_7, NA); - /* For items with localized display names, the dictionary of all available localizations. The keys are the cannonical locale strings for the available localizations. (CFDictionary) */ - -CF_EXPORT const CFStringRef _kCFURLLocalizedTypeDescriptionDictionaryKey CF_AVAILABLE(10_7, NA); - /* The dictionary of all available localizations of the item kind string. The keys are the cannonical locale strings for the available localizations. (CFDictionary) */ - -CF_EXPORT const CFStringRef _kCFURLApplicationCategoriesKey CF_AVAILABLE(10_7, NA); - /* The array of category UTI strings associated with the url. (CFArray) */ - -CF_EXPORT const CFStringRef _kCFURLApplicationHighResolutionModeIsMagnifiedKey CF_AVAILABLE(10_7, NA); - /* True if the app runs with magnified 1x graphics on a 2x display (Per-user, CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLCanSetApplicationHighResolutionModeIsMagnifiedKey CF_AVAILABLE(10_7, NA); - /* True if the app can run in either magnified or native resolution modes (Read only, CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLWriterBundleIdentifierKey CF_AVAILABLE(10_8, NA); - /* The bundle identifier of the process writing to this object (Read-write, value type CFString) */ - -CF_EXPORT const CFStringRef _kCFURLApplicationNapIsDisabledKey CF_AVAILABLE(10_9, NA); - /* True if app nap is disabled (Applications only, Per-user, CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLCanSetApplicationNapIsDisabledKey CF_AVAILABLE(10_9, NA); - /* True if the ApplicationNapIsDisabled property value can be changed (Applications only, Read only, CFBoolean) */ - -/* Additional volume properties */ - -CF_EXPORT const CFStringRef _kCFURLVolumeRefNumKey CF_AVAILABLE(10_6, 4_0); - /* The Carbon File Manager's FSVolumeRefNum for the resource volume (CFNumber) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeUUIDStringKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeUUIDStringKey or NSURLVolumeUUIDStringKey public property keys */ - -CF_EXPORT const CFStringRef _kCFURLVolumeCreationDateKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeCreationDateKey or NSURLVolumeCreationDateKey public property keys */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsLocalKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsLocalKey or NSURLVolumeIsLocalKey public property keys */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsAutomountKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsAutomountedKey or NSURLVolumeIsAutomountedKey public property keys */ - -CF_EXPORT const CFStringRef _kCFURLVolumeDontBrowseKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsBrowsableKey or NSURLVolumeIsBrowsableKey public property keys (Note: value is inverse of _kCFURLVolumeDontBrowseKey) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsReadOnlyKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsReadOnlyKey or NSURLVolumeIsReadOnlyKey public property keys */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsQuarantinedKey CF_AVAILABLE(10_6, 4_0); - /* Mounted quarantined (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsEjectableKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsEjectableKey or NSURLVolumeIsEjectableKey public property keys */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsRemovableKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsRemovableKey or NSURLVolumeIsRemovableKey public property keys */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsInternalKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsInternalKey or NSURLVolumeIsInternalKey public property keys (Note: this has slightly different behavior than the public VolumeIsInternal key) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsExternalKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsInternalKey or NSURLVolumeIsInternalKey public property keys (Note: this has slightly different behavior than the public VolumeIsInternal key) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsDiskImageKey CF_AVAILABLE(10_6, 4_0); - /* Volume is a mounted disk image (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLDiskImageBackingURLKey CF_AVAILABLE(10_6, 4_0); - /* If volume is a mounted disk image, the URL of the backing disk image (CFURL) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsFileVaultKey CF_AVAILABLE(10_6, 4_0); - /* Volume uses File Vault encryption (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsiDiskKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - there are no more iDisks */ - -CF_EXPORT const CFStringRef _kCFURLVolumeiDiskUserNameKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - there are no more iDisks */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsLocaliDiskMirrorKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - there are no more iDisks */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsiPodKey CF_AVAILABLE(10_6, 4_0); - /* Volume is on an iPod (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsCDKey CF_AVAILABLE(10_6, 4_0); - /* Volume is a CD (audio or CD-ROM). (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsDVDKey CF_AVAILABLE(10_6, 4_0); - /* Volume is a DVD (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsDeviceFileSystemKey CF_AVAILABLE(10_7, 5_0); - /* Volume is devfs (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIsHFSStandardKey CF_AVAILABLE(10_6, 4_0); - /* Volume is HFS standard (which includes AFP volumes). Directory IDs, but not file IDs, can be looked up. (CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIOMediaIconFamilyNameKey CF_AVAILABLE(10_9, NA); - /* Volume's IOMediaIconFamilyName. (CFStringRef) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeIOMediaIconBundleIdentifierKey CF_AVAILABLE(10_9, NA); - /* Volume's IOMediaIconBundleIdentifier. (CFStringRef) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeQuarantinePropertiesKey CF_AVAILABLE(10_10, NA); - /* The quarantine properties for the volume on which the resource resides as defined in LSQuarantine.h.=To remove quarantine information from a volume, pass kCFNull as the value when setting this property. (Read-write, value type CFDictionary) */ - -CF_EXPORT const CFStringRef _kCFURLVolumeOpenFolderURLKey CF_AVAILABLE(10_10, NA); - /* Returns a URL to the folder the Finder should open when a HFS volume is mounted, or NULL if there is none. (Read-only, value type CFURL) */ - -CF_EXPORT const CFStringRef _kCFURLResolvedFromBookmarkDataKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal later in 10.9/7.0 since it is unused (*/ - -CF_EXPORT const CFStringRef _kCFURLVolumeMountPointStringKey CF_AVAILABLE(10_6, 4_0); - /* the volume mountpoint string (Read-only, value type CFString) */ - -CF_EXPORT const CFStringRef _kCFURLCompleteMountURLKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeURLForRemountingKey or NSURLVolumeURLForRemountingKey public property keys */ - -CF_EXPORT const CFStringRef _kCFURLUbiquitousItemDownloadRequestedKey CF_AVAILABLE(10_9, 7_0); - /* Is this Ubiquity item scheduled for download? (this is also true for items that are already downloaded). Use startDownloadingUbiquitousItemAtURL:error: to make this true (Read-only, value type CFBoolean) */ - -CF_EXPORT const CFStringRef _kCFURLCloudDocsPlaceholderDictionaryKey CF_AVAILABLE(10_10, 8_0); - /* Returns the placeholder dictionary for a side-fault file (Read-only, value type CFDictionary) */ - -CF_EXPORT const CFStringRef _kCFURLCloudDocsPlaceholderLogicalNameKey CF_AVAILABLE(10_10, 8_0); - /* Returns the placeholder dictionary for a side-fault file (Read-only, value type CFString) */ - -// Temporary holding place for future API. - -CF_EXPORT const CFStringRef kCFURLUbiquitousItemDownloadRequestedKey CF_AVAILABLE(10_9, 7_0); -/* Is this Ubiquity item scheduled for download? (this is also true for items that are already downloaded). Use startDownloadingUbiquitousItemAtURL:error: to make this true (Read-only, value type CFBoolean) */ - -CF_EXPORT const CFStringRef kCFURLUbiquitousItemContainerDisplayNameKey CF_AVAILABLE(10_10, 8_0); - /* Returns the localized name of the ubiquity container that contains this item (Read-only, value type CFString) */ - -CF_EXPORT const CFStringRef kCFURLUbiquitousItemIsSharedKey; // true if the ubiquitous item is shared. (Read-only, value type boolean NSNumber) - -CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemRoleKey /*CF_AVAILABLE(10_11, 9_0)*/; // returns the current user's role for this shared item, or nil if not shared. (Read-only, value type NSString). Possible values below. -CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemRoleOwner /*CF_AVAILABLE(10_11, 9_0)*/; // the current user is the owner of this shared item. -CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemRoleParticipant /*CF_AVAILABLE(10_11, 9_0)*/; // the current user is a participant of this shared item. - -CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemOwnerNameKey /*CF_AVAILABLE(10_11, 9_0)*/; // returns the name of the owner of a shared item, or nil if the current user. (Read-only, value type NSString) - -CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemPermissionsKey /*CF_AVAILABLE(10_11, 9_0)*/; // returns the current user's permissions for this shared item. (Read-only, value type NSString). Possible values below. -CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemPermissionsReadOnly /*CF_AVAILABLE(10_11, 9_0)*/; // the user is only allowed to read this item -CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemPermissionsReadWrite /*CF_AVAILABLE(10_11, 9_0)*/; // the user is allowed to both read and write this item - -// Deprecated. Will be removed. -CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemReadOnlyPermissions /*CF_AVAILABLE(10_11, 9_0)*/; // the user is only allowed to read this item -CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemReadWritePermissions /*CF_AVAILABLE(10_11, 9_0)*/; // the user is allowed to both read and write this item - - -// these keys are defined here, not in CFURL.h, because they return NSImage values which can only be used by Foundation -CF_EXPORT const CFStringRef kCFURLThumbnailDictionaryKey CF_AVAILABLE(10_10, 8_0); -CF_EXPORT const CFStringRef kCFURLThumbnailKey CF_AVAILABLE(10_10, 8_0); -// The values of thumbnails in the dictionary returned by NSURLThumbnailDictionaryKey -CF_EXPORT const CFStringRef kCFThumbnail1024x1024SizeKey CF_AVAILABLE(10_10, 8_0); - - -/* - Some common boolean properties can be accessed as a bitfield - for better performance -- see _CFURLGetResourcePropertyFlags() and - _CFURLCopyResourcePropertyValuesAndFlags(), below. - */ -enum { - kCFURLResourceIsRegularFile = 0x00000001, - kCFURLResourceIsDirectory = 0x00000002, - kCFURLResourceIsSymbolicLink = 0x00000004, - kCFURLResourceIsVolume = 0x00000008, - kCFURLResourceIsPackage = 0x00000010, - kCFURLResourceIsSystemImmutable = 0x00000020, - kCFURLResourceIsUserImmutable = 0x00000040, - kCFURLResourceIsHidden = 0x00000080, - kCFURLResourceHasHiddenExtension = 0x00000100, - kCFURLResourceIsApplication = 0x00000200, - kCFURLResourceIsCompressed = 0x00000400, - kCFURLResourceIsSystemCompressed CF_ENUM_DEPRECATED(10_6, 10_9, 4_0, 7_0) - = 0x00000400, /* Deprecated and scheduled for removal in 10.10/8.0 - Use kCFURLResourceIsCompressed */ - kCFURLCanSetHiddenExtension = 0x00000800, - kCFURLResourceIsReadable = 0x00001000, - kCFURLResourceIsWriteable = 0x00002000, - kCFURLResourceIsExecutable = 0x00004000, /* execute files or search directories */ - kCFURLIsAliasFile = 0x00008000, - kCFURLIsMountTrigger = 0x00010000, -}; -typedef unsigned long long CFURLResourcePropertyFlags; - - -/* - _CFURLGetResourceFlags - Returns a bit array of resource flags in the "flags" - output parameter. Only flags whose corresponding bits are set in the "mask" parameter - are valid in the output bit array. Returns true on success, false if an error occurs. - Optional output error: the error is set to a valid CFErrorRef if and only if the function - returns false. A valid output error must be released by the caller. - */ -CF_EXPORT -Boolean _CFURLGetResourcePropertyFlags(CFURLRef url, CFURLResourcePropertyFlags mask, CFURLResourcePropertyFlags *flags, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - - -/* - File resource properties which can be obtained with _CFURLCopyFilePropertyValuesAndFlags(). - */ -typedef CF_OPTIONS(unsigned long long, CFURLFilePropertyBitmap) { - kCFURLName = 0x0000000000000001, - kCFURLLinkCount = 0x0000000000000002, - kCFURLVolumeIdentifier = 0x0000000000000004, - kCFURLObjectIdentifier = 0x0000000000000008, - kCFURLCreationDate = 0x0000000000000010, - kCFURLContentModificationDate = 0x0000000000000020, - kCFURLAttributeModificationDate = 0x0000000000000040, - kCFURLFileSize = 0x0000000000000080, - kCFURLFileAllocatedSize = 0x0000000000000100, - kCFURLFileSizeOfResourceFork = 0x0000000000000200, - kCFURLFileAllocatedSizeOfResourceFork = 0x0000000000000400, - kCFURLFinderInfo = 0x0000000000000800, - kCFURLFileSecurity = 0x0000000000001000, -}; - -/* - The structure where _CFURLCopyFilePropertyValuesAndFlags() returns file resource properties. - */ -struct _CFURLFilePropertyValues { - CFStringRef name; /* you are responsible for releasing this if you ask for it and get it */ - uint32_t linkCount; - uint64_t volumeIdentifier; - uint64_t objectIdentifier; - CFAbsoluteTime creationDate; - CFAbsoluteTime contentModificationDate; - CFAbsoluteTime attributeModificationDate; - uint64_t fileSize; - uint64_t fileAllocatedSize; - uint64_t fileSizeOfResourceFork; - uint64_t fileAllocatedSizeOfResourceFork; - uint8_t finderInfo[32]; - CFFileSecurityRef fileSecurity; /* you are responsible for releasing this if you ask for it and get it */ -}; -typedef struct _CFURLFilePropertyValues _CFURLFilePropertyValues; - -/* - _CFURLCopyResourcePropertyValuesAndFlags - Returns property values as simple types - whenever possible. Returns a bit array of resource flags in the "flags" - output parameter. Only flags whose corresponding bits are set in the "mask" parameter - are valid in the output bit array. Returns true on success, false if an error occurs. - Optional output error: the error is set to a valid CFErrorRef if and only if the function - returns false. A valid output error must be released by the caller. - */ -CF_EXPORT -Boolean _CFURLCopyResourcePropertyValuesAndFlags( CFURLRef url, CFURLFilePropertyBitmap requestProperties, CFURLFilePropertyBitmap *actualProperties, struct _CFURLFilePropertyValues *properties, CFURLResourcePropertyFlags propertyFlagsMask, CFURLResourcePropertyFlags *propertyFlags, CFErrorRef *error) CF_AVAILABLE(10_7, 4_0); - -/* - Volume property flags - */ -typedef CF_OPTIONS(unsigned long long, CFURLVolumePropertyFlags) { - kCFURLVolumeIsLocal = 0x1LL, // Local device (vs. network device) - kCFURLVolumeIsAutomount = 0x2LL, // Mounted by the automounter - kCFURLVolumeDontBrowse = 0x4LL, // Hidden from user browsing - kCFURLVolumeIsReadOnly = 0x8LL, // Mounted read-only - kCFURLVolumeIsQuarantined = 0x10LL, // Mounted with quarantine bit - kCFURLVolumeIsEjectable = 0x20LL, - kCFURLVolumeIsRemovable = 0x40LL, - kCFURLVolumeIsInternal = 0x80LL, - kCFURLVolumeIsExternal = 0x100LL, - kCFURLVolumeIsDiskImage = 0x200LL, - kCFURLVolumeIsFileVault = 0x400LL, - kCFURLVolumeIsLocaliDiskMirror CF_ENUM_DEPRECATED(10_6, 10_9, 4_0, 7_0) - = 0x800LL, // Deprecated and scheduled for removal in 10.10/8.0 - there are no more iDisks - kCFURLVolumeIsiPod = 0x1000LL, - kCFURLVolumeIsiDisk CF_ENUM_DEPRECATED(10_6, 10_9, 4_0, 7_0) - = 0x2000LL, // Deprecated and scheduled for removal in 10.10/8.0 - there are no more iDisks - kCFURLVolumeIsCD = 0x4000LL, - kCFURLVolumeIsDVD = 0x8000LL, - kCFURLVolumeIsDeviceFileSystem = 0x10000LL, - kCFURLVolumeIsTimeMachine CF_ENUM_AVAILABLE_MAC(10_9) - = 0x20000LL, - kCFURLVolumeIsAirport CF_ENUM_AVAILABLE_MAC(10_9) - = 0x40000LL, - kCFURLVolumeIsVideoDisk CF_ENUM_AVAILABLE_MAC(10_9) - = 0x80000LL, - kCFURLVolumeIsDVDVideo CF_ENUM_AVAILABLE_MAC(10_9) - = 0x100000LL, - kCFURLVolumeIsBDVideo CF_ENUM_AVAILABLE_MAC(10_9) - = 0x200000LL, - kCFURLVolumeIsMobileTimeMachine CF_ENUM_AVAILABLE_MAC(10_9) - = 0x400000LL, - kCFURLVolumeIsNetworkOptical CF_ENUM_AVAILABLE_MAC(10_9) - = 0x800000LL, - kCFURLVolumeIsBeingRepaired CF_ENUM_AVAILABLE_MAC(10_9) - = 0x1000000LL, - kCFURLVolumeIsBeingUnmounted CF_ENUM_AVAILABLE_MAC(10_9) - = 0x2000000LL, - -// IMPORTANT: The values of the following flags must stay in sync with the -// VolumeCapabilities flags in CarbonCore (FileIDTreeStorage.h) - kCFURLVolumeSupportsPersistentIDs = 0x100000000LL, - kCFURLVolumeSupportsSearchFS = 0x200000000LL, - kCFURLVolumeSupportsExchange = 0x400000000LL, - // reserved 0x800000000LL, - kCFURLVolumeSupportsSymbolicLinks = 0x1000000000LL, - kCFURLVolumeSupportsDenyModes = 0x2000000000LL, - kCFURLVolumeSupportsCopyFile = 0x4000000000LL, - kCFURLVolumeSupportsReadDirAttr = 0x8000000000LL, - kCFURLVolumeSupportsJournaling = 0x10000000000LL, - kCFURLVolumeSupportsRename = 0x20000000000LL, - kCFURLVolumeSupportsFastStatFS = 0x40000000000LL, - kCFURLVolumeSupportsCaseSensitiveNames = 0x80000000000LL, - kCFURLVolumeSupportsCasePreservedNames = 0x100000000000LL, - kCFURLVolumeSupportsFLock = 0x200000000000LL, - kCFURLVolumeHasNoRootDirectoryTimes = 0x400000000000LL, - kCFURLVolumeSupportsExtendedSecurity = 0x800000000000LL, - kCFURLVolumeSupports2TBFileSize = 0x1000000000000LL, - kCFURLVolumeSupportsHardLinks = 0x2000000000000LL, - kCFURLVolumeSupportsMandatoryByteRangeLocks = 0x4000000000000LL, - kCFURLVolumeSupportsPathFromID = 0x8000000000000LL, - // reserved 0x10000000000000LL, - kCFURLVolumeIsJournaling = 0x20000000000000LL, - kCFURLVolumeSupportsSparseFiles = 0x40000000000000LL, - kCFURLVolumeSupportsZeroRuns = 0x80000000000000LL, - kCFURLVolumeSupportsVolumeSizes = 0x100000000000000LL, - kCFURLVolumeSupportsRemoteEvents = 0x200000000000000LL, - kCFURLVolumeSupportsHiddenFiles = 0x400000000000000LL, - kCFURLVolumeSupportsDecmpFSCompression = 0x800000000000000LL, - kCFURLVolumeHas64BitObjectIDs = 0x1000000000000000LL, - kCFURLVolumePropertyFlagsAll = 0xffffffffffffffffLL -}; - - -/* - _CFURLGetVolumePropertyFlags - Returns a bit array of volume properties. - Only flags whose corresponding bits are set in the "mask" parameter are valid - in the output bit array. Returns true on success, false if an error occurs. - Optional output error: the error is set to a valid CFErrorRef if and only if the function - returns false. A valid output error must be released by the caller. - */ -CF_EXPORT -Boolean _CFURLGetVolumePropertyFlags(CFURLRef url, CFURLVolumePropertyFlags mask, CFURLVolumePropertyFlags *flags, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - - -/* _CFURLCopyResourcePropertyForKeyFromCache works like CFURLCopyResourcePropertyForKey - only it never causes I/O. If the property value requested is cached (or known - to be not available) for the resource, return TRUE and the property value. The - property value returned could be NULL meaning that property is not available - for the resource. If the property value requested is not cached or the resource, - FALSE is returned. - - Only for use by DesktopServices! - */ -CF_EXPORT -Boolean _CFURLCopyResourcePropertyForKeyFromCache(CFURLRef url, CFStringRef key, void *cfTypeRefValue) CF_AVAILABLE(10_8, NA); - -/* _CFURLCopyResourcePropertiesForKeysFromCache works like CFURLCopyResourcePropertiesForKeys - only it never causes I/O. If the property values requested are cached (or known - to be not available) for the resource, return a CFDictionary. Property values - not available for the resource are not included in the CFDictionary. - If the values requested are not cached, return NULL. - - Only for use by DesktopServices! - */ -CF_EXPORT -CFDictionaryRef _CFURLCopyResourcePropertiesForKeysFromCache(CFURLRef url, CFArrayRef keys) CF_AVAILABLE(10_8, NA); - -/* _CFURLCacheResourcePropertyForKey works like CFURLCopyResourcePropertyForKey - only it does not return the property value -- it just ensures the value is cached. - If no errors occur, TRUE is returned. If an error occurs, FALSE is returned - and the optional output error is set to a valid CFErrorRef (which must be - released by the caller. - - Only for use by DesktopServices! - */ -CF_EXPORT -Boolean _CFURLCacheResourcePropertyForKey(CFURLRef url, CFStringRef key, CFErrorRef *error) CF_AVAILABLE(10_8, NA); - -/* _CFURLCacheResourcePropertiesForKeys works like CFURLCopyResourcePropertiesForKeys - only it does not return the property values -- it just ensures the values is cached. - If no errors occur, TRUE is returned. If an error occurs, FALSE is returned - and the optional output error is set to a valid CFErrorRef (which must be - released by the caller. - - Only for use by DesktopServices! - */ -CF_EXPORT -Boolean _CFURLCacheResourcePropertiesForKeys(CFURLRef url, CFArrayRef keys, CFErrorRef *error) CF_AVAILABLE(10_8, NA); - -/* - _CFURLCreateDisplayPathComponentsArray() - - Summary: - _FileURLCreateDisplayPathComponentsArray creates a CFArray of - CFURLs for each component in the path leading up to the target - URL. This routine is suitable for clients who wish to show the - path leading up to a file system item. NOTE: This routine can be - I/O intensive, so use it sparingly, and cache the results if - possible. - - Discussion: - The CFURLs in the result CFArray are ordered from the target URL - to the root of the display path. For example, if the target URL - is file://localhost/System/Library/ the CFURLs in the array will - be ordered: file://localhost/System/Library/, - file://localhost/System/, and then file://localhost/ - - Parameters: - - targetURL: - The target URL. - - error: - A pointer to a CFErrorRef, or NULL. If error is non-NULL and - the function result is NULL, this will be filled in with a - CFErrorRef representing the error that occurred. - - Result: - A CFArray or NULL if an error occurred. - */ -CF_EXPORT -CFArrayRef _CFURLCreateDisplayPathComponentsArray(CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_7, 4_0); - -/* Returns true for URLs that locate file system resources. */ -CF_EXPORT -Boolean _CFURLIsFileURL(CFURLRef url) CF_AVAILABLE(10_6, 4_0); - -/* Deprecated and scheduled for removal in 10.10/8.0 - Use the public API CFURLIsFileReferenceURL() */ -CF_EXPORT -Boolean _CFURLIsFileReferenceURL(CFURLRef url) CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); - -/* For use by Core Services */ -CF_EXPORT -void *__CFURLResourceInfoPtr(CFURLRef url) CF_AVAILABLE(10_6, 4_0); - -CF_EXPORT -void __CFURLSetResourceInfoPtr(CFURLRef url, void *ptr) CF_AVAILABLE(10_6, 4_0); - - -struct FSCatalogInfo; -struct HFSUniStr255; - -/* _CFURLGetCatalogInfo is used by LaunchServices */ -CF_EXPORT -SInt32 _CFURLGetCatalogInfo(CFURLRef url, UInt32 whichInfo, struct FSCatalogInfo *catalogInfo, struct HFSUniStr255 *name) CF_AVAILABLE(10_7, 5_0); - -/* _CFURLReplaceObject SPI */ - -/* options for _CFURLReplaceObject */ -enum { -// _CFURLItemReplacementUsingOriginalMetadataOnly = 1, // not used - _CFURLItemReplacementUsingNewMetadataOnly = 2, -// _CFURLItemReplacementByMergingMetadata = 3, // not used - _CFURLItemReplacementWithoutDeletingBackupItem = 1 << 4 -}; - -/* _CFURLReplaceObject is the underlying implementation for -[NSFileManager replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error:] with one additional argument: newName. The optional newName argument can be used to rename the replacement (for example, when replacing "document.rtf" with "document.rtfd") while still preserving the document's metadata. If newName is used, there must be a file or directory at originalItemURL -- if originalItemURL does not exist and newName is not NULL, an error will be returned. - */ -CF_EXPORT -Boolean _CFURLReplaceObject( CFAllocatorRef allocator, CFURLRef originalItemURL, CFURLRef newItemURL, CFStringRef newName, CFStringRef backupItemName, CFOptionFlags options, CFURLRef *resultingURL, CFErrorRef *error ) CF_AVAILABLE(10_7, 5_0); - -CF_EXPORT -Boolean _CFURLIsProtectedDirectory(CFURLRef directoryURL) CF_AVAILABLE(10_10, NA); - -/* _CFURLAttachSecurityScopeToFileURL attaches a sandbox extension to the file URL object. The URL object will then be security-scoped and will be usable with the NSURL's -startAccessingSecurityScopedResource method and CFURL's CFURLStartAccessingSecurityScopedResource() function. The URL object must be a file URL. If the URL object already has a sandbox extension attached, the new extension replaces the previous sandbox extension. If NULL is passed for the sandboxExtension, the sandbox extension (if any) is removed from the URL object. Callers would be responsible for ensuring the sandbox extension matches the URL's file system path. - */ -CF_EXPORT -void _CFURLAttachSecurityScopeToFileURL(CFURLRef url, CFDataRef sandboxExtension) CF_AVAILABLE(10_10, 8_0); - -/* _CFURLCopySecurityScopeFromFileURL copies the sandbox extension attached to the file URL object. If the URL is not a file URL or doesn't have a sandbox extension, NULL will be returned. - */ -CF_EXPORT -CFDataRef _CFURLCopySecurityScopeFromFileURL(CFURLRef url) CF_AVAILABLE(10_10, 8_0); - -CF_EXPORT -void _CFURLSetPermanentResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue) CF_AVAILABLE(10_10, 8_0); - -CF_EXPORT -CFURLEnumeratorResult _CFURLEnumeratorGetURLsBulk(CFURLEnumeratorRef enumerator, CFIndex maximumURLs, CFIndex *actualURLs, CFURLRef *urls, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); - -// Returns a string describing the bookmark data. For debugging purposes only. -CF_EXPORT -CFStringRef _CFURLBookmarkCopyDescription(CFDataRef bookmarkRef) CF_AVAILABLE(10_10, 8_0); - -// private CFURLBookmarkCreationOptions -enum { - kCFURLBookmarkCreationWithFileProvider CF_ENUM_AVAILABLE(10_10, 8_0) = ( 1UL << 26 ), // private option to create bookmarks with file provider string. The file provider string overrides the rest of the bookmark data at resolution time. - kCFURLBookmarkOperatingInsideScopedBookmarksAgent = (1UL << 27), // private option used internally by ScopedBookmarkAgent to prevent recursion between the agent and the framework code. Available 10_7, NA - kCFURLBookmarkCreationAllowCreationIfResourceDoesNotExistMask = ( 1UL << 28 ), // allow creation of a bookmark to a file: scheme with a CFURLRef of item which may not exist. If the filesystem item does not exist, the created bookmark contains essentially no properties beyond the url string. Available 10_7, 5_0. - kCFURLBookmarkCreationDoNotIncludeSandboxExtensionsMask = ( 1UL << 29 ), // If set, sandbox extensions are not included in created bookmarks. Ordinarily, bookmarks (except those created suitable for putting into a bookmark file) will have a sandbox extension added for the item. Available 10_7, NA. - kCFURLBookmarkCreationSuitableForOdocAppleEvent = ( 1UL << 31 ), // add properties we guarantee will be in an odoc AppleEvent. Available 10_10, NA (but supported back to 10.6). -}; - -// private CFURLBookmarkFileCreationOptions -enum { - // FIXME: These three options (kCFBookmarkFileCreationWithoutOverwritingExistingFile, kCFBookmarkFileCreationWithoutAppendingAliasExtension, and kCFBookmarkFileCreationWithoutCreatingResourceFork) are not implemented and have never been used. - kCFBookmarkFileCreationWithoutOverwritingExistingFile = ( 1UL << 8 ), // if destination file already exists don't overwrite it and return an error - kCFBookmarkFileCreationWithoutAppendingAliasExtension = ( 1UL << 9 ), // don't add / change whatever extension is on the created alias file - kCFBookmarkFileCreationWithoutCreatingResourceFork = ( 1UL << 10 ), // don't create the resource-fork half of the alias file -}; - -// private CFURLBookmarkResolutionOptions -enum { - kCFBookmarkResolutionPerformRelativeResolutionFirstMask CF_ENUM_AVAILABLE(10_8, 6_0) = ( 1UL << 11 ), // perform relative resolution before absolute resolution. If this bit is set, for this to be useful a relative URL must also have been passed in and the bookmark when created must have been created relative to another url. -}; - -typedef CF_ENUM(CFIndex, CFURLBookmarkMatchResult) { - kCFURLBookmarkComparisonUnableToCompare = 0x00000000, /* the two bookmarks could not be compared for some reason */ - kCFURLBookmarkComparisonNoMatch = 0x00001000, /* Bookmarks do not refer to the same item */ - kCFURLBookmarkComparisonUnlikelyToMatch = 0x00002000, /* it is unlikely that the two items refer to the same filesystem item */ - kCFURLBookmarkComparisonLikelyToMatch = 0x00004000, /* it is likely that the two items refer to the same filesystem item ( but, they may not ) */ - kCFURLBookmarkComparisonMatch = 0x00008000, /* the two items refer to the same item, but other information in the bookmarks may not match */ - kCFURLBookmarkComparisonExactMatch = 0x0000f000 /* the two bookmarks are identical */ -}; // Available 10_7, NA. - -/* The relativeToURL and matchingPropertyKeys parameters are not used and are ignored */ -CF_EXPORT -CFURLBookmarkMatchResult _CFURLBookmarkDataCompare(CFDataRef bookmark1Ref, CFDataRef bookmark2Ref, CFURLRef relativeToURL, CFArrayRef* matchingPropertyKeys) CF_AVAILABLE(10_7, NA); - -CF_EXPORT -OSStatus _CFURLBookmarkDataToAliasHandle(CFDataRef bookmarkRef, void* aliasHandleP) CF_AVAILABLE(10_7, NA); - -CF_EXPORT -CFURLRef _CFURLCreateByResolvingAliasFile(CFAllocatorRef allocator, CFURLRef url, CFURLBookmarkResolutionOptions options, CFArrayRef propertiesToInclude, CFErrorRef *error ) CF_AVAILABLE(10_10, 8_0); - -/* - The following are properties that can be asked of bookmark data objects in addition to the resource properties - from CFURL itself. - */ - -extern const CFStringRef kCFURLBookmarkOriginalPathKey CF_AVAILABLE(10_7, 5_0); -extern const CFStringRef kCFURLBookmarkOriginalRelativePathKey CF_AVAILABLE(10_7, 5_0); -extern const CFStringRef kCFURLBookmarkOriginalRelativePathComponentsArrayKey CF_AVAILABLE(10_7, 5_0); -extern const CFStringRef kCFURLBookmarkOriginalVolumeNameKey CF_AVAILABLE(10_7, 5_0); -extern const CFStringRef kCFURLBookmarkOriginalVolumeCreationDateKey CF_AVAILABLE(10_7, 5_0); -extern const CFStringRef kCFURLBookmarkFileProviderStringKey CF_AVAILABLE(10_10, 8_0); - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFURLPRIV__ */ - diff --git a/CFURLPriv.h b/CFURLPriv.h new file mode 120000 index 0000000..a661e0e --- /dev/null +++ b/CFURLPriv.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFURLPriv.h \ No newline at end of file diff --git a/CFUUID.h b/CFUUID.h deleted file mode 100644 index acdde5a..0000000 --- a/CFUUID.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFUUID.h - Copyright (c) 1999-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFUUID__) -#define __COREFOUNDATION_CFUUID__ 1 - -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef const struct __CFUUID * CFUUIDRef; - -typedef struct { - 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; -} CFUUIDBytes; -/* The CFUUIDBytes struct is a 128-bit struct that contains the -raw UUID. A CFUUIDRef can provide such a struct from the -CFUUIDGetUUIDBytes() function. This struct is suitable for -passing to APIs that expect a raw UUID. -*/ - -CF_EXPORT -CFTypeID CFUUIDGetTypeID(void); - -CF_EXPORT -CFUUIDRef CFUUIDCreate(CFAllocatorRef alloc); - /* Create and return a brand new unique identifier */ - -CF_EXPORT -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); - /* Create and return an identifier with the given contents. This may return an existing instance with its ref count bumped because of uniquing. */ - -CF_EXPORT -CFUUIDRef CFUUIDCreateFromString(CFAllocatorRef alloc, CFStringRef uuidStr); - /* Converts from a string representation to the UUID. This may return an existing instance with its ref count bumped because of uniquing. */ - -CF_EXPORT -CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); - /* Converts from a UUID to its string representation. */ - -CF_EXPORT -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); - /* This returns an immortal CFUUIDRef that should not be released. It can be used in headers to declare UUID constants with #define. */ - -CF_EXPORT -CFUUIDBytes CFUUIDGetUUIDBytes(CFUUIDRef uuid); - -CF_EXPORT -CFUUIDRef CFUUIDCreateFromUUIDBytes(CFAllocatorRef alloc, CFUUIDBytes bytes); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFUUID__ */ - diff --git a/CFUUID.h b/CFUUID.h new file mode 120000 index 0000000..c3a7114 --- /dev/null +++ b/CFUUID.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFUUID.h \ No newline at end of file diff --git a/CFUniChar.h b/CFUniChar.h deleted file mode 100644 index 8eb5440..0000000 --- a/CFUniChar.h +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFUniChar.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFUNICHAR__) -#define __COREFOUNDATION_CFUNICHAR__ 1 - - -#include -#include - -CF_EXTERN_C_BEGIN - -#define kCFUniCharBitShiftForByte (3) -#define kCFUniCharBitShiftForMask (7) - -CF_INLINE bool CFUniCharIsSurrogateHighCharacter(UniChar character) { - return ((character >= 0xD800UL) && (character <= 0xDBFFUL) ? true : false); -} - -CF_INLINE bool CFUniCharIsSurrogateLowCharacter(UniChar character) { - return ((character >= 0xDC00UL) && (character <= 0xDFFFUL) ? true : false); -} - -CF_INLINE UTF32Char CFUniCharGetLongCharacterForSurrogatePair(UniChar surrogateHigh, UniChar surrogateLow) { - return ((surrogateHigh - 0xD800UL) << 10) + (surrogateLow - 0xDC00UL) + 0x0010000UL; -} - -// The following values coinside TextEncodingFormat format defines in TextCommon.h -enum { - kCFUniCharUTF16Format = 0, - kCFUniCharUTF8Format = 2, - kCFUniCharUTF32Format = 3 -}; - -CF_INLINE bool CFUniCharIsMemberOfBitmap(UTF16Char theChar, const uint8_t *bitmap) { - return (bitmap && (bitmap[(theChar) >> kCFUniCharBitShiftForByte] & (((uint32_t)1) << (theChar & kCFUniCharBitShiftForMask))) ? true : false); -} - -CF_INLINE void CFUniCharAddCharacterToBitmap(UTF16Char theChar, uint8_t *bitmap) { - bitmap[(theChar) >> kCFUniCharBitShiftForByte] |= (((uint32_t)1) << (theChar & kCFUniCharBitShiftForMask)); -} - -CF_INLINE void CFUniCharRemoveCharacterFromBitmap(UTF16Char theChar, uint8_t *bitmap) { - bitmap[(theChar) >> kCFUniCharBitShiftForByte] &= ~(((uint32_t)1) << (theChar & kCFUniCharBitShiftForMask)); -} - -enum { - kCFUniCharControlCharacterSet = 1, - kCFUniCharWhitespaceCharacterSet, - kCFUniCharWhitespaceAndNewlineCharacterSet, - kCFUniCharDecimalDigitCharacterSet, - kCFUniCharLetterCharacterSet, - kCFUniCharLowercaseLetterCharacterSet, - kCFUniCharUppercaseLetterCharacterSet, - kCFUniCharNonBaseCharacterSet, - kCFUniCharCanonicalDecomposableCharacterSet, - kCFUniCharDecomposableCharacterSet = kCFUniCharCanonicalDecomposableCharacterSet, - kCFUniCharAlphaNumericCharacterSet, - kCFUniCharPunctuationCharacterSet, - kCFUniCharIllegalCharacterSet, - kCFUniCharTitlecaseLetterCharacterSet, - kCFUniCharSymbolAndOperatorCharacterSet, - kCFUniCharNewlineCharacterSet, - - kCFUniCharCompatibilityDecomposableCharacterSet = 100, // internal character sets begins here - kCFUniCharHFSPlusDecomposableCharacterSet, - kCFUniCharStrongRightToLeftCharacterSet, - kCFUniCharHasNonSelfLowercaseCharacterSet, - kCFUniCharHasNonSelfUppercaseCharacterSet, - kCFUniCharHasNonSelfTitlecaseCharacterSet, - kCFUniCharHasNonSelfCaseFoldingCharacterSet, - kCFUniCharHasNonSelfMirrorMappingCharacterSet, - kCFUniCharControlAndFormatterCharacterSet, - kCFUniCharCaseIgnorableCharacterSet, - kCFUniCharGraphemeExtendCharacterSet -}; - -CF_EXPORT bool CFUniCharIsMemberOf(UTF32Char theChar, uint32_t charset); - -// This function returns NULL for kCFUniCharControlCharacterSet, kCFUniCharWhitespaceCharacterSet, kCFUniCharWhitespaceAndNewlineCharacterSet, & kCFUniCharIllegalCharacterSet -CF_EXPORT const uint8_t *CFUniCharGetBitmapPtrForPlane(uint32_t charset, uint32_t plane); - -enum { - kCFUniCharBitmapFilled = (uint8_t)0, - kCFUniCharBitmapEmpty = (uint8_t)0xFF, - kCFUniCharBitmapAll = (uint8_t)1 -}; - -CF_EXPORT uint8_t CFUniCharGetBitmapForPlane(uint32_t charset, uint32_t plane, void *bitmap, bool isInverted); - -CF_EXPORT uint32_t CFUniCharGetNumberOfPlanes(uint32_t charset); - -enum { - kCFUniCharToLowercase = 0, - kCFUniCharToUppercase, - kCFUniCharToTitlecase, - kCFUniCharCaseFold -}; - -enum { - kCFUniCharCaseMapFinalSigma = (1UL << 0), - kCFUniCharCaseMapAfter_i = (1UL << 1), - kCFUniCharCaseMapMoreAbove = (1UL << 2), - kCFUniCharCaseMapDutchDigraph = (1UL << 3), - kCFUniCharCaseMapGreekTonos = (1UL << 4) -}; - -CF_EXPORT CFIndex CFUniCharMapCaseTo(UTF32Char theChar, UTF16Char *convertedChar, CFIndex maxLength, uint32_t ctype, uint32_t flags, const uint8_t *langCode); - -CF_EXPORT uint32_t CFUniCharGetConditionalCaseMappingFlags(UTF32Char theChar, UTF16Char *buffer, CFIndex currentIndex, CFIndex length, uint32_t type, const uint8_t *langCode, uint32_t lastFlags); - -enum { - kCFUniCharBiDiPropertyON = 0, - kCFUniCharBiDiPropertyL, - kCFUniCharBiDiPropertyR, - kCFUniCharBiDiPropertyAN, - kCFUniCharBiDiPropertyEN, - kCFUniCharBiDiPropertyAL, - kCFUniCharBiDiPropertyNSM, - kCFUniCharBiDiPropertyCS, - kCFUniCharBiDiPropertyES, - kCFUniCharBiDiPropertyET, - kCFUniCharBiDiPropertyBN, - kCFUniCharBiDiPropertyS, - kCFUniCharBiDiPropertyWS, - kCFUniCharBiDiPropertyB, - kCFUniCharBiDiPropertyRLO, - kCFUniCharBiDiPropertyRLE, - kCFUniCharBiDiPropertyLRO, - kCFUniCharBiDiPropertyLRE, - kCFUniCharBiDiPropertyPDF -}; - -enum { - kCFUniCharCombiningProperty = 0, - kCFUniCharBidiProperty -}; - -// The second arg 'bitmap' has to be the pointer to a specific plane -CF_INLINE uint8_t CFUniCharGetBidiPropertyForCharacter(UTF16Char character, const uint8_t *bitmap) { - if (bitmap) { - uint8_t value = bitmap[(character >> 8)]; - - if (value > kCFUniCharBiDiPropertyPDF) { - bitmap = bitmap + 256 + ((value - kCFUniCharBiDiPropertyPDF - 1) * 256); - return bitmap[character % 256]; - } else { - return value; - } - } - return kCFUniCharBiDiPropertyL; -} - -CF_INLINE uint8_t CFUniCharGetCombiningPropertyForCharacter(UTF16Char character, const uint8_t *bitmap) { - if (bitmap) { - uint8_t value = bitmap[(character >> 8)]; - - if (value) { - bitmap = bitmap + 256 + ((value - 1) * 256); - return bitmap[character % 256]; - } - } - return 0; -} - -CF_EXPORT const void *CFUniCharGetUnicodePropertyDataForPlane(uint32_t propertyType, uint32_t plane); -CF_EXPORT uint32_t CFUniCharGetNumberOfPlanesForUnicodePropertyData(uint32_t propertyType); -CF_EXPORT uint32_t CFUniCharGetUnicodeProperty(UTF32Char character, uint32_t propertyType); - -CF_EXPORT bool CFUniCharFillDestinationBuffer(const UTF32Char *src, CFIndex srcLength, void **dst, CFIndex dstLength, CFIndex *filledLength, uint32_t dstFormat); - -// UTF32 support - -CF_INLINE bool CFUniCharToUTF32(const UTF16Char *src, CFIndex length, UTF32Char *dst, bool allowLossy, bool isBigEndien) { - const UTF16Char *limit = src + length; - UTF32Char character; - - while (src < limit) { - character = *(src++); - - if (CFUniCharIsSurrogateHighCharacter(character)) { - if ((src < limit) && CFUniCharIsSurrogateLowCharacter(*src)) { - character = CFUniCharGetLongCharacterForSurrogatePair(character, *(src++)); - } else { - if (!allowLossy) return false; - character = 0xFFFD; // replacement character - } - } else if (CFUniCharIsSurrogateLowCharacter(character)) { - if (!allowLossy) return false; - character = 0xFFFD; // replacement character - } - - *(dst++) = (isBigEndien ? CFSwapInt32HostToBig(character) : CFSwapInt32HostToLittle(character)); - } - - return true; -} - -CF_INLINE bool CFUniCharFromUTF32(const UTF32Char *src, CFIndex length, UTF16Char *dst, bool allowLossy, bool isBigEndien) { - const UTF32Char *limit = src + length; - UTF32Char character; - - while (src < limit) { - character = (isBigEndien ? CFSwapInt32BigToHost(*(src++)) : CFSwapInt32LittleToHost(*(src++))); - - if (character < 0x10000) { // BMP - if (allowLossy) { - if (CFUniCharIsSurrogateHighCharacter(character)) { - UTF32Char otherCharacter = 0xFFFD; // replacement character - - if (src < limit) { - otherCharacter = (isBigEndien ? CFSwapInt32BigToHost(*src) : CFSwapInt32LittleToHost(*src)); - - - if ((otherCharacter < 0x10000) && CFUniCharIsSurrogateLowCharacter(otherCharacter)) { - *(dst++) = character; ++src; - } else { - otherCharacter = 0xFFFD; // replacement character - } - } - - character = otherCharacter; - } else if (CFUniCharIsSurrogateLowCharacter(character)) { - character = 0xFFFD; // replacement character - } - } else { - if (CFUniCharIsSurrogateHighCharacter(character) || CFUniCharIsSurrogateLowCharacter(character)) return false; - } - } else if (character < 0x110000) { // non-BMP - character -= 0x10000; - *(dst++) = (UTF16Char)((character >> 10) + 0xD800UL); - character = (UTF16Char)((character & 0x3FF) + 0xDC00UL); - } else { - if (!allowLossy) return false; - character = 0xFFFD; // replacement character - } - - *(dst++) = character; - } - return true; -} - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFUNICHAR__ */ - diff --git a/CFUniChar.h b/CFUniChar.h new file mode 120000 index 0000000..2be4e34 --- /dev/null +++ b/CFUniChar.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFUniChar.h \ No newline at end of file diff --git a/CFUniCharPriv.h b/CFUniCharPriv.h deleted file mode 100644 index eb5a0b9..0000000 --- a/CFUniCharPriv.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFUniCharPriv.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFUNICHARPRIV__) -#define __COREFOUNDATION_CFUNICHARPRIV__ 1 - -#include -#include - -#define kCFUniCharRecursiveDecompositionFlag (1UL << 30) -#define kCFUniCharNonBmpFlag (1UL << 31) -#define CFUniCharConvertCountToFlag(count) ((count & 0x1F) << 24) -#define CFUniCharConvertFlagToCount(flag) ((flag >> 24) & 0x1F) - -enum { - kCFUniCharCanonicalDecompMapping = (kCFUniCharCaseFold + 1), - kCFUniCharCanonicalPrecompMapping, - kCFUniCharCompatibilityDecompMapping -}; - -CF_EXPORT const void *CFUniCharGetMappingData(uint32_t type); - -#endif /* ! __COREFOUNDATION_CFUNICHARPRIV__ */ - diff --git a/CFUniCharPriv.h b/CFUniCharPriv.h new file mode 120000 index 0000000..dd123cf --- /dev/null +++ b/CFUniCharPriv.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFUniCharPriv.h \ No newline at end of file diff --git a/CFUnicodeDecomposition.h b/CFUnicodeDecomposition.h deleted file mode 100644 index 5623c86..0000000 --- a/CFUnicodeDecomposition.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* - * CFUnicodeDecomposition.h - * CoreFoundation - * - * Created by aki on Wed Oct 03 2001. - * Copyright (c) 2001-2014, Apple Inc. All rights reserved. - * - */ - -#if !defined(__COREFOUNDATION_CFUNICODEDECOMPOSITION__) -#define __COREFOUNDATION_CFUNICODEDECOMPOSITION__ 1 - -#include - -CF_EXTERN_C_BEGIN - -CF_INLINE bool CFUniCharIsDecomposableCharacter(UTF32Char character, bool isHFSPlusCanonical) { - if (isHFSPlusCanonical && !isHFSPlusCanonical) return false; // hack to get rid of "unused" warning - if (character < 0x80) return false; - return CFUniCharIsMemberOf(character, kCFUniCharHFSPlusDecomposableCharacterSet); -} - -CF_EXPORT CFIndex CFUniCharDecomposeCharacter(UTF32Char character, UTF32Char *convertedChars, CFIndex maxBufferLength); -CF_EXPORT CFIndex CFUniCharCompatibilityDecompose(UTF32Char *convertedChars, CFIndex length, CFIndex maxBufferLength); - -CF_EXPORT bool CFUniCharDecompose(const UTF16Char *src, CFIndex length, CFIndex *consumedLength, void *dst, CFIndex maxLength, CFIndex *filledLength, bool needToReorder, uint32_t dstFormat, bool isHFSPlus); - -CF_EXPORT void CFUniCharPrioritySort(UTF32Char *characters, CFIndex length); - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFUNICODEDECOMPOSITION__ */ - diff --git a/CFUnicodeDecomposition.h b/CFUnicodeDecomposition.h new file mode 120000 index 0000000..9d5164f --- /dev/null +++ b/CFUnicodeDecomposition.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFUnicodeDecomposition.h \ No newline at end of file diff --git a/CFUnicodePrecomposition.h b/CFUnicodePrecomposition.h deleted file mode 100644 index 821d02c..0000000 --- a/CFUnicodePrecomposition.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* - * CFUnicodePrecomposition.h - * CoreFoundation - * - * Created by aki on Wed Oct 03 2001. - * Copyright (c) 2001-2014, Apple Inc. All rights reserved. - * - */ - -#if !defined(__COREFOUNDATION_CFUNICODEPRECOMPOSITION__) -#define __COREFOUNDATION_CFUNICODEPRECOMPOSITION__ 1 - -#include - -CF_EXTERN_C_BEGIN - -// As you can see, this function cannot precompose Hangul Jamo -CF_EXPORT UTF32Char CFUniCharPrecomposeCharacter(UTF32Char base, UTF32Char combining); - -CF_EXPORT bool CFUniCharPrecompose(const UTF16Char *characters, CFIndex length, CFIndex *consumedLength, UTF16Char *precomposed, CFIndex maxLength, CFIndex *filledLength); - -CF_EXTERN_C_END - -#endif /* ! __COREFOUNDATION_CFUNICODEPRECOMPOSITION__ */ - diff --git a/CFUnicodePrecomposition.h b/CFUnicodePrecomposition.h new file mode 120000 index 0000000..865b401 --- /dev/null +++ b/CFUnicodePrecomposition.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFUnicodePrecomposition.h \ No newline at end of file diff --git a/CFUserNotification.h b/CFUserNotification.h deleted file mode 100644 index f87a8e6..0000000 --- a/CFUserNotification.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFUserNotification.h - Copyright (c) 2000-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFUSERNOTIFICATION__) -#define __COREFOUNDATION_CFUSERNOTIFICATION__ 1 - -#include -#include -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct __CFUserNotification * CFUserNotificationRef; - -/* A CFUserNotification is a notification intended to be presented to a -user at the console (if one is present). This is for the use of processes -that do not otherwise have user interfaces, but may need occasional -interaction with a user. There is a parallel API for this functionality -at the System framework level, described in UNCUserNotification.h. - -The contents of the notification can include a header, a message, textfields, -a popup button, radio buttons or checkboxes, a progress indicator, and up to -three ordinary buttons. All of these items are optional, but a default -button will be supplied even if not specified unless the -kCFUserNotificationNoDefaultButtonFlag is set. - -The contents of the notification are specified in the dictionary used to -create the notification, whose keys should be taken from the list of constants -below, and whose values should be either strings or arrays of strings -(except for kCFUserNotificationProgressIndicatorValueKey, in which case the -value should be a number between 0 and 1, for a "definite" progress indicator, -or a boolean, for an "indefinite" progress indicator). Additionally, URLs can -optionally be supplied for an icon, a sound, and a bundle whose Localizable.strings -files will be used to localize strings. - -Certain request flags are specified when a notification is created. -These specify an alert level for the notification, determine whether -radio buttons or check boxes are to be used, specify which if any of these -are checked by default, specify whether any of the textfields are to -be secure textfields, and determine which popup item should be selected -by default. A timeout is also specified, which determines how long the -notification should be supplied to the user (if zero, it will not timeout). - -A CFUserNotification is dispatched for presentation when it is created. -If any reply is required, it may be awaited in one of two ways: either -synchronously, using CFUserNotificationReceiveResponse, or asynchronously, -using a run loop source. CFUserNotificationReceiveResponse has a timeout -parameter that determines how long it will block (zero meaning indefinitely) -and it may be called as many times as necessary until a response arrives. -If a notification has not yet received a response, it may be updated with -new information, or it may be cancelled. Notifications may not be reused. - -When a response arrives, it carries with it response flags that describe -which button was used to dismiss the notification, which checkboxes or -radio buttons were checked, and what the selection of the popup was. -It also carries a response dictionary, which describes the contents -of the textfields. */ - -typedef void (*CFUserNotificationCallBack)(CFUserNotificationRef userNotification, CFOptionFlags responseFlags); - -CF_EXPORT -CFTypeID CFUserNotificationGetTypeID(void); - -CF_EXPORT -CFUserNotificationRef CFUserNotificationCreate(CFAllocatorRef allocator, CFTimeInterval timeout, CFOptionFlags flags, SInt32 *error, CFDictionaryRef dictionary); - -CF_EXPORT -SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags *responseFlags); - -CF_EXPORT -CFStringRef CFUserNotificationGetResponseValue(CFUserNotificationRef userNotification, CFStringRef key, CFIndex idx); - -CF_EXPORT -CFDictionaryRef CFUserNotificationGetResponseDictionary(CFUserNotificationRef userNotification); - -CF_EXPORT -SInt32 CFUserNotificationUpdate(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags flags, CFDictionaryRef dictionary); - -CF_EXPORT -SInt32 CFUserNotificationCancel(CFUserNotificationRef userNotification); - -CF_EXPORT -CFRunLoopSourceRef CFUserNotificationCreateRunLoopSource(CFAllocatorRef allocator, CFUserNotificationRef userNotification, CFUserNotificationCallBack callout, CFIndex order); - -/* Convenience functions for handling the simplest and most common cases: -a one-way notification, and a notification with up to three buttons. */ - -CF_EXPORT -SInt32 CFUserNotificationDisplayNotice(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle); - -CF_EXPORT -SInt32 CFUserNotificationDisplayAlert(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle, CFStringRef alternateButtonTitle, CFStringRef otherButtonTitle, CFOptionFlags *responseFlags); - - -/* Flags */ - -enum { - kCFUserNotificationStopAlertLevel = 0, - kCFUserNotificationNoteAlertLevel = 1, - kCFUserNotificationCautionAlertLevel = 2, - kCFUserNotificationPlainAlertLevel = 3 -}; - -enum { - kCFUserNotificationDefaultResponse = 0, - kCFUserNotificationAlternateResponse = 1, - kCFUserNotificationOtherResponse = 2, - kCFUserNotificationCancelResponse = 3 -}; - -enum { - kCFUserNotificationNoDefaultButtonFlag = (1UL << 5), - kCFUserNotificationUseRadioButtonsFlag = (1UL << 6) -}; - -CF_INLINE CFOptionFlags CFUserNotificationCheckBoxChecked(CFIndex i) {return ((CFOptionFlags)(1UL << (8 + i)));} -CF_INLINE CFOptionFlags CFUserNotificationSecureTextField(CFIndex i) {return ((CFOptionFlags)(1UL << (16 + i)));} -CF_INLINE CFOptionFlags CFUserNotificationPopUpSelection(CFIndex n) {return ((CFOptionFlags)(n << 24));} - - -/* Keys */ - -CF_EXPORT -const CFStringRef kCFUserNotificationIconURLKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationSoundURLKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationLocalizationURLKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationAlertHeaderKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationAlertMessageKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationDefaultButtonTitleKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationAlternateButtonTitleKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationOtherButtonTitleKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationProgressIndicatorValueKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationPopUpTitlesKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationTextFieldTitlesKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationCheckBoxTitlesKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationTextFieldValuesKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationPopUpSelectionKey CF_AVAILABLE(10_3, NA); - -#if (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -CF_EXPORT -const CFStringRef kCFUserNotificationAlertTopMostKey; - -CF_EXPORT -const CFStringRef kCFUserNotificationKeyboardTypesKey; -#endif - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFUSERNOTIFICATION__ */ - diff --git a/CFUserNotification.h b/CFUserNotification.h new file mode 120000 index 0000000..bad94c4 --- /dev/null +++ b/CFUserNotification.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFUserNotification.h \ No newline at end of file diff --git a/CFUtilities.h b/CFUtilities.h deleted file mode 100644 index a49b595..0000000 --- a/CFUtilities.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFUtilities.h - Copyright (c) 2005-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFUTILITIES__) -#define __COREFOUNDATION_CFUTILITIES__ 1 - -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -CF_EXPORT -CFURLRef CFCopyHomeDirectoryURL(void) CF_AVAILABLE_IOS(5_0); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFUTILITIES__ */ - diff --git a/CFUtilities.h b/CFUtilities.h new file mode 120000 index 0000000..cba036e --- /dev/null +++ b/CFUtilities.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFUtilities.h \ No newline at end of file diff --git a/CFXMLInputStream.h b/CFXMLInputStream.h deleted file mode 100644 index a876b07..0000000 --- a/CFXMLInputStream.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFXMLInputStream.h - Copyright (c) 2000-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_CFXMLINPUTSTREAM__) -#define __COREFOUNDATION_CFXMLINPUTSTREAM__ 1 - -#include -#include "CFInternal.h" -#include -#include -#include - -struct __CFXMLNode { - // 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 - CFRuntimeBase _cfBase; - CFIndex version; - CFXMLNodeTypeCode dataTypeID; - CFStringRef dataString; - void *additionalData; -}; - -struct __CFXMLInputStream { - CFDataRef data; // The XML data - CFURLRef url; // the source URL for the data - CFStringEncoding encoding; // the data's encoding - const UInt8 *currentByte; // pointer into data at the first byte not yet translated to a character - - UniChar *charBuffer; // the buffer of characters translated from data - UniChar *currentChar; // pointer into charBuffer at the current stream location. MUST be NULL if there are no more characters in charBuffer to consume. - UniChar *mark; // The point at which the mark was dropped. NULL if the mark is currently unset. - UniChar *parserMark; // mark available only for the parser's use - CFIndex bufferLength; // The number of meaningful characters in charBuffer - CFIndex bufferCapacity; // The current maximum capacity of charBuffer in UniChars - - CFIndex charIndex, lineNum; // location in the file - UInt32 flags; // See #defines below for bit flag meanings - CFMutableSetRef nameSet; // set of all names we've encountered; used for uniquing - CFMutableStringRef tempString; - - 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 -}; - -// whether the stream has been opened for reading -#define STREAM_OPEN 0x1 -// whether the encoding matches ASCII over 0x0-0x7F -#define ENCODING_MATCHES_ASCII 0x2 -// whether the encoding is Unicode with the "natural" byte ordering -#define ENCODING_IS_UNICODE_NATURAL 0x4 -// whether the encoding is Unicode with the bytes swapped -#define ENCODING_IS_UNICODE_SWAPPED 0x8 -// whether the stream has encountered an error in encodings. -#define ENCODING_COMPOSITION_ERROR 0x10 - -typedef struct __CFXMLInputStream _CFXMLInputStream; - -void _initializeInputStream(_CFXMLInputStream *stream, CFAllocatorRef alloc, CFURLRef dataSource, CFDataRef xmlData); -Boolean _openInputStream(_CFXMLInputStream *stream); // None of the subsequent calls will work until the input stream has been opened -void _freeInputStream(_CFXMLInputStream *stream); - -CFStringEncoding _inputStreamGetEncoding(_CFXMLInputStream *stream); -CFIndex _inputStreamCurrentLocation(_CFXMLInputStream *stream); -CFIndex _inputStreamCurrentLine(_CFXMLInputStream *stream); -Boolean _inputStreamAtEOF(_CFXMLInputStream *stream); -Boolean _inputStreamComposingErrorOccurred(_CFXMLInputStream *stream); - -Boolean _inputStreamPeekCharacter(_CFXMLInputStream *stream, UniChar *ch); -Boolean _inputStreamGetCharacter(_CFXMLInputStream *stream, UniChar *ch); -Boolean _inputStreamReturnCharacter(_CFXMLInputStream *stream, UniChar ch); -void _inputStreamSetMark(_CFXMLInputStream *stream); -void _inputStreamClearMark(_CFXMLInputStream *stream); -void _inputStreamGetCharactersFromMark(_CFXMLInputStream *stream, CFMutableStringRef string); -void _inputStreamBackUpToMark(_CFXMLInputStream *stream); -void _inputStringInitialize(_CFXMLInputStream *stream, UniChar *characters, CFIndex length); -CFIndex _inputStreamSkipWhitespace(_CFXMLInputStream *stream, CFMutableStringRef str); -Boolean _inputStreamScanToCharacters(_CFXMLInputStream *stream, const UniChar *scanChars, CFIndex numChars, CFMutableStringRef str); -Boolean _inputStreamMatchString(_CFXMLInputStream *stream, const UniChar *stringToMatch, CFIndex length); -Boolean _inputStreamScanQuotedString(_CFXMLInputStream *stream, CFMutableStringRef str); -Boolean _inputStreamScanXMLName(_CFXMLInputStream *stream, Boolean isNMToken, CFStringRef *str); - -/* Returns the character index within the current line of the current parse location */ -/* To add someday -- CF_EXPORT -CFIndex CFXMLParserGetOffsetInCurrentLine(CFXMLParserRef parser); */ - -#endif /* ! __COREFOUNDATION_CFXMLINPUTSTREAM__ */ - diff --git a/CFXMLInputStream.h b/CFXMLInputStream.h new file mode 120000 index 0000000..380e172 --- /dev/null +++ b/CFXMLInputStream.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFXMLInputStream.h \ No newline at end of file diff --git a/CFXMLNode.h b/CFXMLNode.h deleted file mode 100644 index 7750168..0000000 --- a/CFXMLNode.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFXMLNode.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -/* CFXMLParser (and thus CFXMLNode) are deprecated as of Mac OS X 10.8 and iOS 6.0. The suggested replacements are the Foundation classes NSXMLParser and NSXMLDocument, or the libxml2 library. */ - -#if !defined(__COREFOUNDATION_CFXMLNODE__) -#define __COREFOUNDATION_CFXMLNODE__ 1 - -#include -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -enum { - kCFXMLNodeCurrentVersion = 1 -}; - -typedef const struct __CFXMLNode * CFXMLNodeRef; -typedef CFTreeRef CFXMLTreeRef; - -/* An CFXMLNode describes an individual XML construct - like a tag, or a comment, or a string - of character data. Each CFXMLNode contains 3 main pieces of information - the node's type, - the data string, and a pointer to an additional data structure. The node's type ID is an enum - value of type CFXMLNodeTypeID. The data string is always a CFStringRef; the meaning of the - string is dependent on the node's type ID. The format of the additional data is also dependent - on the node's type; in general, there is a custom structure for each type that requires - additional data. See below for the mapping from type ID to meaning of the data string and - structure of the additional data. Note that these structures are versioned, and may change - as the parser changes. The current version can always be identified by kCFXMLNodeCurrentVersion; - earlier versions can be identified and used by passing earlier values for the version number - (although the older structures would have been removed from the header). - - An CFXMLTree is simply a CFTree whose context data is known to be an CFXMLNodeRef. As - such, an CFXMLTree can be used to represent an entire XML document; the CFTree - provides the tree structure of the document, while the CFXMLNodes identify and describe - the nodes of the tree. An XML document can be parsed to a CFXMLTree, and a CFXMLTree - can generate the data for the equivalent XML document - see CFXMLParser.h for more - information on parsing XML. - */ - -/* Type codes for the different possible XML nodes; this list may grow.*/ -typedef CF_ENUM(CFIndex, CFXMLNodeTypeCode) { - kCFXMLNodeTypeDocument = 1, - kCFXMLNodeTypeElement = 2, - kCFXMLNodeTypeAttribute = 3, - kCFXMLNodeTypeProcessingInstruction = 4, - kCFXMLNodeTypeComment = 5, - kCFXMLNodeTypeText = 6, - kCFXMLNodeTypeCDATASection = 7, - kCFXMLNodeTypeDocumentFragment = 8, - kCFXMLNodeTypeEntity = 9, - kCFXMLNodeTypeEntityReference = 10, - kCFXMLNodeTypeDocumentType = 11, - kCFXMLNodeTypeWhitespace = 12, - kCFXMLNodeTypeNotation = 13, - kCFXMLNodeTypeElementTypeDeclaration = 14, - kCFXMLNodeTypeAttributeListDeclaration = 15 -}; - -typedef struct { - CFDictionaryRef attributes; - CFArrayRef attributeOrder; - Boolean isEmpty; - char _reserved[3]; -} CFXMLElementInfo; - -typedef struct { - CFStringRef dataString; -} CFXMLProcessingInstructionInfo; - -typedef struct { - CFURLRef sourceURL; - CFStringEncoding encoding; -} CFXMLDocumentInfo; - -typedef struct { - CFURLRef systemID; - CFStringRef publicID; -} CFXMLExternalID; - -typedef struct { - CFXMLExternalID externalID; -} CFXMLDocumentTypeInfo; - -typedef struct { - CFXMLExternalID externalID; -} CFXMLNotationInfo; - -typedef struct { - /* This is expected to change in future versions */ - CFStringRef contentDescription; -} CFXMLElementTypeDeclarationInfo; - -typedef struct { - /* This is expected to change in future versions */ - CFStringRef attributeName; - CFStringRef typeString; - CFStringRef defaultString; -} CFXMLAttributeDeclarationInfo; - -typedef struct { - CFIndex numberOfAttributes; - CFXMLAttributeDeclarationInfo *attributes; -} CFXMLAttributeListDeclarationInfo; - -typedef CF_ENUM(CFIndex, CFXMLEntityTypeCode) { - kCFXMLEntityTypeParameter, /* Implies parsed, internal */ - kCFXMLEntityTypeParsedInternal, - kCFXMLEntityTypeParsedExternal, - kCFXMLEntityTypeUnparsed, - kCFXMLEntityTypeCharacter -}; - -typedef struct { - CFXMLEntityTypeCode entityType; - CFStringRef replacementText; /* NULL if entityType is external or unparsed */ - CFXMLExternalID entityID; /* entityID.systemID will be NULL if entityType is internal */ - CFStringRef notationName; /* NULL if entityType is parsed */ -} CFXMLEntityInfo; - -typedef struct { - CFXMLEntityTypeCode entityType; -} CFXMLEntityReferenceInfo; - -/* - dataTypeCode meaning of dataString format of infoPtr - =========== ===================== ================= - kCFXMLNodeTypeDocument CFXMLDocumentInfo * - kCFXMLNodeTypeElement tag name CFXMLElementInfo * - kCFXMLNodeTypeAttribute - kCFXMLNodeTypeProcessingInstruction name of the target CFXMLProcessingInstructionInfo * - kCFXMLNodeTypeComment text of the comment NULL - kCFXMLNodeTypeText the text's contents NULL - kCFXMLNodeTypeCDATASection text of the CDATA NULL - kCFXMLNodeTypeDocumentFragment - kCFXMLNodeTypeEntity name of the entity CFXMLEntityInfo * - kCFXMLNodeTypeEntityReference name of the referenced entity CFXMLEntityReferenceInfo * - kCFXMLNodeTypeDocumentType name given as top-level element CFXMLDocumentTypeInfo * - kCFXMLNodeTypeWhitespace text of the whitespace NULL - kCFXMLNodeTypeNotation notation name CFXMLNotationInfo * - kCFXMLNodeTypeElementTypeDeclaration tag name CFXMLElementTypeDeclarationInfo * - kCFXMLNodeTypeAttributeListDeclaration tag name CFXMLAttributeListDeclarationInfo * -*/ - -CF_EXPORT -CFTypeID CFXMLNodeGetTypeID(void) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Creates a new node based on xmlType, dataString, and additionalInfoPtr. version (together with xmlType) determines the expected structure of additionalInfoPtr */ -CF_EXPORT -CFXMLNodeRef CFXMLNodeCreate(CFAllocatorRef alloc, CFXMLNodeTypeCode xmlType, CFStringRef dataString, const void *additionalInfoPtr, CFIndex version) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Creates a copy of origNode (which may not be NULL). */ -CF_EXPORT -CFXMLNodeRef CFXMLNodeCreateCopy(CFAllocatorRef alloc, CFXMLNodeRef origNode) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXPORT -CFXMLNodeTypeCode CFXMLNodeGetTypeCode(CFXMLNodeRef node) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXPORT -CFStringRef CFXMLNodeGetString(CFXMLNodeRef node) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXPORT -const void *CFXMLNodeGetInfoPtr(CFXMLNodeRef node) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXPORT -CFIndex CFXMLNodeGetVersion(CFXMLNodeRef node) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* CFXMLTreeRef */ - -/* Creates a childless, parentless tree from node */ -CF_EXPORT -CFXMLTreeRef CFXMLTreeCreateWithNode(CFAllocatorRef allocator, CFXMLNodeRef node) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Extracts and returns the node stored in xmlTree */ -CF_EXPORT -CFXMLNodeRef CFXMLTreeGetNode(CFXMLTreeRef xmlTree) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFXMLNODE__ */ - diff --git a/CFXMLNode.h b/CFXMLNode.h new file mode 120000 index 0000000..0cd7e53 --- /dev/null +++ b/CFXMLNode.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFXMLNode.h \ No newline at end of file diff --git a/CFXMLParser.h b/CFXMLParser.h deleted file mode 100644 index 325e21d..0000000 --- a/CFXMLParser.h +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CFXMLParser.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -/* CFXMLParser is deprecated as of Mac OS X 10.8. The suggested replacements are the Foundation classes NSXMLParser and NSXMLDocument, or the libxml2 library. */ - -#if !defined(__COREFOUNDATION_CFXMLPARSER__) -#define __COREFOUNDATION_CFXMLPARSER__ 1 - -#include -#include -#include -#include -#include -#include -#include - -CF_IMPLICIT_BRIDGING_ENABLED -CF_EXTERN_C_BEGIN - -typedef struct __CFXMLParser * CFXMLParserRef; - -/* These are the various options you can configure the parser with. These are - chosen such that an option flag of 0 (kCFXMLParserNoOptions) leaves the XML - as "intact" as possible (reports all structures; performs no replacements). - Hence, to make the parser do the most work, returning only the pure element - tree, set the option flag to kCFXMLParserAllOptions. - -kCFXMLParserValidateDocument - - validate the document against its grammar from the DTD, reporting any errors. - Currently not supported. - -kCFXMLParserSkipMetaData - - silently skip over metadata constructs (the DTD and comments) - -kCFXMLParserReplacePhysicalEntities - - replace declared entities like <. Note that other than the 5 predefined - entities (lt, gt, quot, amp, apos), these must be defined in the DTD. - Currently not supported. - -kCFXMLParserSkipWhitespace - - skip over all whitespace that does not abut non-whitespace character data. - In other words, given blah , the whitespace between - foo's open tag and bar's open tag would be suppressed, but the whitespace - around blah would be preserved. - -kCFXMLParserAddImpliedAttributes - - where the DTD specifies implied attribute-value pairs for a particular element, - add those pairs to any occurances of the element in the element tree. - Currently not supported. -*/ - -typedef CF_OPTIONS(CFOptionFlags, CFXMLParserOptions) { - kCFXMLParserValidateDocument = (1UL << 0), - kCFXMLParserSkipMetaData = (1UL << 1), - kCFXMLParserReplacePhysicalEntities = (1UL << 2), - kCFXMLParserSkipWhitespace = (1UL << 3), - kCFXMLParserResolveExternalEntities = (1UL << 4), - kCFXMLParserAddImpliedAttributes = (1UL << 5), - kCFXMLParserAllOptions = 0x00FFFFFF, - kCFXMLParserNoOptions = 0 -}; - -/* This list is expected to grow */ -typedef CF_OPTIONS(CFIndex, CFXMLParserStatusCode) { - kCFXMLStatusParseNotBegun = -2, - kCFXMLStatusParseInProgress = -1, - kCFXMLStatusParseSuccessful = 0, - kCFXMLErrorUnexpectedEOF = 1, - kCFXMLErrorUnknownEncoding, - kCFXMLErrorEncodingConversionFailure, - kCFXMLErrorMalformedProcessingInstruction, - kCFXMLErrorMalformedDTD, - kCFXMLErrorMalformedName, - kCFXMLErrorMalformedCDSect, - kCFXMLErrorMalformedCloseTag, - kCFXMLErrorMalformedStartTag, - kCFXMLErrorMalformedDocument, - kCFXMLErrorElementlessDocument, - kCFXMLErrorMalformedComment, - kCFXMLErrorMalformedCharacterReference, - kCFXMLErrorMalformedParsedCharacterData, - kCFXMLErrorNoData -}; - - -/* These functions are called as a parse progresses. - -createXMLStructure - - called as new XML structures are encountered by the parser. May return NULL to indicate - that the given structure should be skipped; if NULL is returned for a given structure, - only minimal parsing is done for that structure (enough to correctly determine its end, - and to extract any data necessary for the remainder of the parse, such as Entity definitions). - createXMLStructure (or indeed, any of the tree-creation callbacks) will not be called for any - children of the skipped structure. The only exception is that the top-most element will always - be reported even if NULL was returned for the document as a whole. NOTE: for performance reasons, - the node passed to createXMLStructure cannot be safely retained by the client; the node as - a whole must be copied (via CFXMLNodeCreateCopy), or its contents must be extracted and copied. - -addChild - - called as children are parsed and are ready to be added to the tree. If createXMLStructure - returns NULL for a given structure, that structure is omitted entirely, and addChild will - NOT be called for either a NULL child or parent. - -endXMLStructure - - called once a structure (and all its children) are completely parsed. As elements are encountered, - createXMLStructure is called for them first, then addChild to add the new structure to its parent, - then addChild (potentially several times) to add the new structure's children to it, then finally - endXMLStructure to show that the structure has been fully parsed. - -createXMLStructure, addChild, and endXMLStructure are all REQUIRED TO BE NON-NULL. - -resolveExternalEntity - - called when external entities are referenced (NOT when they are simply defined). If the function - pointer is NULL, the parser uses its internal routines to try and resolve the entity. If the - function pointer is set, and the function returns NULL, a place holder for the external entity - is inserted into the tree. In this manner, the parser's client can prevent any external network - or file accesses. - -handleError - called as errors/warnings are encountered in the data stream. At some point, we will - have an enum of the expected errors, some of which will be fatal, others of which will not. If - the function pointer is NULL, the parser will silently attempt to recover. The - handleError function may always return false to force the parser to stop; if handleError returns - true, the parser will attempt to recover (fatal errors will still cause the parse to abort - immediately). -*/ - -typedef void * (*CFXMLParserCreateXMLStructureCallBack)(CFXMLParserRef parser, CFXMLNodeRef nodeDesc, void *info); -typedef void (*CFXMLParserAddChildCallBack)(CFXMLParserRef parser, void *parent, void *child, void *info); -typedef void (*CFXMLParserEndXMLStructureCallBack)(CFXMLParserRef parser, void *xmlType, void *info); -typedef CFDataRef (*CFXMLParserResolveExternalEntityCallBack)(CFXMLParserRef parser, CFXMLExternalID *extID, void *info); -typedef Boolean (*CFXMLParserHandleErrorCallBack)(CFXMLParserRef parser, CFXMLParserStatusCode error, void *info); -typedef struct { - CFIndex version; - CFXMLParserCreateXMLStructureCallBack createXMLStructure; - CFXMLParserAddChildCallBack addChild; - CFXMLParserEndXMLStructureCallBack endXMLStructure; - CFXMLParserResolveExternalEntityCallBack resolveExternalEntity; - CFXMLParserHandleErrorCallBack handleError; -} CFXMLParserCallBacks; - -typedef const void * (*CFXMLParserRetainCallBack)(const void *info); -typedef void (*CFXMLParserReleaseCallBack)(const void *info); -typedef CFStringRef (*CFXMLParserCopyDescriptionCallBack)(const void *info); -typedef struct { - CFIndex version; - void * info; - CFXMLParserRetainCallBack retain; - CFXMLParserReleaseCallBack release; - CFXMLParserCopyDescriptionCallBack copyDescription; -} CFXMLParserContext; - -CF_EXPORT -CFTypeID CFXMLParserGetTypeID(void) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Creates a parser which will parse the given data with the given options. xmlData may not be NULL. - dataSource should be the URL from which the data came, and may be NULL; it is used to resolve any - relative references found in xmlData. versionOfNodes determines which version CFXMLNodes are produced - by the parser; see CFXMLNode.h for more details. callBacks are the callbacks called by the parser as - the parse progresses; callBacks, callBacks->createXMLStructure, callBacks->addChild, and - callBacks->endXMLStructure must all be non-NULL. context determines what if any info pointer is - passed to the callbacks as the parse progresses; context may be NULL. */ -CF_EXPORT -CFXMLParserRef CFXMLParserCreate(CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes, CFXMLParserCallBacks *callBacks, CFXMLParserContext *context) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Arguments as above, except that the data to be parsed is loaded directly - from dataSource. dataSource may not be NULL. */ -CF_EXPORT -CFXMLParserRef CFXMLParserCreateWithDataFromURL(CFAllocatorRef allocator, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes, CFXMLParserCallBacks *callBacks, CFXMLParserContext *context) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXPORT -void CFXMLParserGetContext(CFXMLParserRef parser, CFXMLParserContext *context) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXPORT -void CFXMLParserGetCallBacks(CFXMLParserRef parser, CFXMLParserCallBacks *callBacks) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXPORT -CFURLRef CFXMLParserGetSourceURL(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Returns the character index of the current parse location */ -CF_EXPORT -CFIndex CFXMLParserGetLocation(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Returns the line number of the current parse location */ -CF_EXPORT -CFIndex CFXMLParserGetLineNumber(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Returns the top-most object returned by the createXMLStructure callback */ -CF_EXPORT -void *CFXMLParserGetDocument(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Get the status code or a user-readable description of the last error that occurred in a parse. - If no error has occurred, a null description string is returned. See the enum above for - possible status returns */ -CF_EXPORT -CFXMLParserStatusCode CFXMLParserGetStatusCode(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -CF_EXPORT -CFStringRef CFXMLParserCopyErrorDescription(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Cause any in-progress parse to abort with the given error code and description. errorCode - must be positive, and errorDescription may not be NULL. Cannot be called asynchronously - (i.e. must be called from within a parser callback) */ -CF_EXPORT -void CFXMLParserAbort(CFXMLParserRef parser, CFXMLParserStatusCode errorCode, CFStringRef errorDescription) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Starts a parse of the data the parser was created with; returns success or failure. - Upon success, use CFXMLParserGetDocument() to get the product of the parse. Upon - failure, use CFXMLParserGetErrorCode() or CFXMLParserCopyErrorDescription() to get - information about the error. It is an error to call CFXMLParserParse() while a - parse is already underway. */ -CF_EXPORT -Boolean CFXMLParserParse(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* These functions provide a higher-level interface. The XML data is parsed to a - special CFTree (an CFXMLTree) with known contexts and callbacks. See CFXMLNode.h - for full details on using an CFXMLTree and the CFXMLNodes contained therein. -*/ -/* Parse to an CFXMLTreeRef. parseOptions are as above. versionOfNodes determines - what version CFXMLNodes are used to populate the tree. */ -CF_EXPORT -CFXMLTreeRef CFXMLTreeCreateFromData(CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* As above, with the additional by-reference pass of a CFDictionaryRef containing - various error information (see below). The caller is responsible for releasing the - returned dictionary. If the error dictionary is not desired, pass NULL. */ -CF_EXPORT -CFXMLTreeRef CFXMLTreeCreateFromDataWithError(CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes, CFDictionaryRef *errorDict) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Loads the data to be parsed directly from dataSource. Arguments as above. */ -CF_EXPORT -CFXMLTreeRef CFXMLTreeCreateWithDataFromURL(CFAllocatorRef allocator, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Generate the XMLData (ready to be written to whatever permanent storage is to be - used) from an CFXMLTree. Will NOT regenerate entity references (except those - required for syntactic correctness) if they were replaced at the parse time; - clients that wish this should walk the tree and re-insert any entity references - that should appear in the final output file. */ -CF_EXPORT -CFDataRef CFXMLTreeCreateXMLData(CFAllocatorRef allocator, CFXMLTreeRef xmlTree) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); - -/* Escaping and unescaping XML entities in CFStrings. The standard XML entities - are always replaced. */ -/* Creates a CFString by replacing entities that appear in the entities dictionary. - Dictionary keys are the entities themselves, and the values should be CFStrings - containing the expansion. Pass NULL for entitiesDictionary to indicate no entities - other than the standard five. */ -CF_EXPORT -CFStringRef CFXMLCreateStringByEscapingEntities(CFAllocatorRef allocator, CFStringRef string, CFDictionaryRef entitiesDictionary); - -CF_EXPORT -CFStringRef CFXMLCreateStringByUnescapingEntities(CFAllocatorRef allocator, CFStringRef string, CFDictionaryRef entitiesDictionary); - -/* CFXMLTreeCreateFromDataWithError error dictionary key constants. */ -CF_EXPORT const CFStringRef kCFXMLTreeErrorDescription; - /* value is a CFString containing the readable error string. */ - -CF_EXPORT const CFStringRef kCFXMLTreeErrorLineNumber; - /* value is a CFNumber containing the line on which the error appears. */ - -CF_EXPORT const CFStringRef kCFXMLTreeErrorLocation; - /* value is a CFNumber containing the byte location at which the error occurred. */ - -CF_EXPORT const CFStringRef kCFXMLTreeErrorStatusCode; - /* value is a CFNumber containing the error status code. */ - -CF_EXTERN_C_END -CF_IMPLICIT_BRIDGING_DISABLED - -#endif /* ! __COREFOUNDATION_CFXMLPARSER__ */ - diff --git a/CFXMLParser.h b/CFXMLParser.h new file mode 120000 index 0000000..74020d3 --- /dev/null +++ b/CFXMLParser.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFXMLParser.h \ No newline at end of file diff --git a/CFXPCBridge.h b/CFXPCBridge.h deleted file mode 100644 index 272abf8..0000000 --- a/CFXPCBridge.h +++ /dev/null @@ -1,37 +0,0 @@ -/* CFXPCBridge.h - - Copyright (C) 2016 Lubos Dolezel - - This file is part of the GNUstep CoreBase Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; see the file COPYING.LIB. - If not, see or write to the - Free Software Foundation, 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef __CFCOREFOUNDATION_CFXPC_H__ -#define __CFCOREFOUNDATION_CFXPC_H__ -#include -#include - -CF_EXTERN_C_BEGIN - -extern CFTypeRef _CFXPCCreateCFObjectFromXPCObject(xpc_object_t xpcattrs); - -extern xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef attrs); - -CF_EXTERN_C_END - -#endif diff --git a/CFXPCBridge.h b/CFXPCBridge.h new file mode 120000 index 0000000..6340673 --- /dev/null +++ b/CFXPCBridge.h @@ -0,0 +1 @@ +include/CoreFoundation/./CFXPCBridge.h \ No newline at end of file diff --git a/CoreFoundation b/CoreFoundation deleted file mode 120000 index 945c9b4..0000000 --- a/CoreFoundation +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file diff --git a/CoreFoundation.h b/CoreFoundation.h deleted file mode 100644 index e4dd439..0000000 --- a/CoreFoundation.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* CoreFoundation.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !defined(__COREFOUNDATION_COREFOUNDATION__) -#define __COREFOUNDATION_COREFOUNDATION__ 1 -#define __COREFOUNDATION__ 1 - -#if !defined(CF_EXCLUDE_CSTD_HEADERS) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(__STDC_VERSION__) && (199901L <= __STDC_VERSION__) - -#include -#include -#include - -#endif - -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || TARGET_OS_WIN32 -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#endif - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) -#endif - -#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) -#include -#include -#include -#endif - - -#endif /* ! __COREFOUNDATION_COREFOUNDATION__ */ - diff --git a/CoreFoundation.h b/CoreFoundation.h new file mode 120000 index 0000000..e73f17f --- /dev/null +++ b/CoreFoundation.h @@ -0,0 +1 @@ +include/CoreFoundation/./CoreFoundation.h \ No newline at end of file diff --git a/ForFoundationOnly.h b/ForFoundationOnly.h deleted file mode 100644 index 7495625..0000000 --- a/ForFoundationOnly.h +++ /dev/null @@ -1,639 +0,0 @@ -/* - * Copyright (c) 2015 Apple Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -/* ForFoundationOnly.h - Copyright (c) 1998-2014, Apple Inc. All rights reserved. -*/ - -#if !CF_BUILDING_CF && !NSBUILDINGFOUNDATION - #error The header file ForFoundationOnly.h is for the exclusive use of the - #error CoreFoundation and Foundation projects. No other project should include it. -#endif - -#if !defined(__COREFOUNDATION_FORFOUNDATIONONLY__) -#define __COREFOUNDATION_FORFOUNDATIONONLY__ 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// NOTE: miscellaneous declarations are at the end - -// ---- CFRuntime material ---------------------------------------- - -CF_EXTERN_C_BEGIN - -#if DEPLOYMENT_TARGET_LINUX -#include -#elif DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI -#include -#endif - -CF_EXTERN_C_END - -// ---- CFBundle material ---------------------------------------- - -#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI || DEPLOYMENT_TARGET_WINDOWS -#include - -CF_EXTERN_C_BEGIN - -CF_EXPORT const CFStringRef _kCFBundleExecutablePathKey; -CF_EXPORT const CFStringRef _kCFBundleInfoPlistURLKey; -CF_EXPORT const CFStringRef _kCFBundleRawInfoPlistURLKey; -CF_EXPORT const CFStringRef _kCFBundleNumericVersionKey; -CF_EXPORT const CFStringRef _kCFBundleResourcesFileMappedKey; -CF_EXPORT const CFStringRef _kCFBundleAllowMixedLocalizationsKey; -CF_EXPORT const CFStringRef _kCFBundleInitialPathKey; -CF_EXPORT const CFStringRef _kCFBundleResolvedPathKey; -CF_EXPORT const CFStringRef _kCFBundlePrincipalClassKey; - -#if __BLOCKS__ -CF_EXPORT CFTypeRef _CFBundleCopyFindResources(CFBundleRef bundle, CFURLRef bundleURL, CFArrayRef _unused_pass_null_, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subPath, CFStringRef lproj, Boolean returnArray, Boolean localized, Boolean (^predicate)(CFStringRef filename, Boolean *stop)); -#endif - -CF_EXPORT Boolean _CFBundleLoadExecutableAndReturnError(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error); -CF_EXPORT CFErrorRef _CFBundleCreateError(CFAllocatorRef allocator, CFBundleRef bundle, CFIndex code); - -CF_EXTERN_C_END - -#endif - -// ---- CFPreferences material ---------------------------------------- - -#define DEBUG_PREFERENCES_MEMORY 0 - -#if DEBUG_PREFERENCES_MEMORY -#include "../Tests/CFCountingAllocator.h" -#endif - -CF_EXTERN_C_BEGIN - -extern void _CFPreferencesPurgeDomainCache(void); - -typedef struct { - void * (*createDomain)(CFAllocatorRef allocator, CFTypeRef context); - void (*freeDomain)(CFAllocatorRef allocator, CFTypeRef context, void *domain); - CFTypeRef (*fetchValue)(CFTypeRef context, void *domain, CFStringRef key); // Caller releases - void (*writeValue)(CFTypeRef context, void *domain, CFStringRef key, CFTypeRef value); - Boolean (*synchronize)(CFTypeRef context, void *domain); - void (*getKeysAndValues)(CFAllocatorRef alloc, CFTypeRef context, void *domain, void **buf[], CFIndex *numKeyValuePairs); - CFDictionaryRef (*copyDomainDictionary)(CFTypeRef context, void *domain); - /* HACK - see comment on _CFPreferencesDomainSetIsWorldReadable(), below */ - void (*setIsWorldReadable)(CFTypeRef context, void *domain, Boolean isWorldReadable); -} _CFPreferencesDomainCallBacks; - -CF_EXPORT CFAllocatorRef __CFPreferencesAllocator(void); -CF_EXPORT const _CFPreferencesDomainCallBacks __kCFVolatileDomainCallBacks; -CF_EXPORT const _CFPreferencesDomainCallBacks __kCFXMLPropertyListDomainCallBacks; - -typedef struct __CFPreferencesDomain * CFPreferencesDomainRef; - -CF_EXPORT CFPreferencesDomainRef _CFPreferencesDomainCreate(CFTypeRef context, const _CFPreferencesDomainCallBacks *callBacks); -CF_EXPORT CFPreferencesDomainRef _CFPreferencesStandardDomain(CFStringRef domainName, CFStringRef userName, CFStringRef hostName); - -CF_EXPORT CFTypeRef _CFPreferencesDomainCreateValueForKey(CFPreferencesDomainRef domain, CFStringRef key); -CF_EXPORT void _CFPreferencesDomainSet(CFPreferencesDomainRef domain, CFStringRef key, CFTypeRef value); -CF_EXPORT Boolean _CFPreferencesDomainSynchronize(CFPreferencesDomainRef domain); - -CF_EXPORT CFArrayRef _CFPreferencesCreateDomainList(CFStringRef userName, CFStringRef hostName); -CF_EXPORT Boolean _CFSynchronizeDomainCache(void); - -CF_EXPORT void _CFPreferencesDomainSetDictionary(CFPreferencesDomainRef domain, CFDictionaryRef dict); -CF_EXPORT CFDictionaryRef _CFPreferencesDomainDeepCopyDictionary(CFPreferencesDomainRef domain); -CF_EXPORT Boolean _CFPreferencesDomainExists(CFStringRef domainName, CFStringRef userName, CFStringRef hostName); - -/* HACK - this is to work around the fact that individual domains lose the information about their user/host/app triplet at creation time. We should find a better way to propogate this information. REW, 1/13/00 */ -CF_EXPORT void _CFPreferencesDomainSetIsWorldReadable(CFPreferencesDomainRef domain, Boolean isWorldReadable); - -typedef struct { - CFMutableArrayRef _search; // the search list; an array of _CFPreferencesDomains - CFMutableDictionaryRef _dictRep; // Mutable; a collapsed view of the search list, expressed as a single dictionary - CFStringRef _appName; -} _CFApplicationPreferences; - -CF_EXPORT _CFApplicationPreferences *_CFStandardApplicationPreferences(CFStringRef appName); -CF_EXPORT _CFApplicationPreferences *_CFApplicationPreferencesCreateWithUser(CFStringRef userName, CFStringRef appName); -CF_EXPORT void _CFDeallocateApplicationPreferences(_CFApplicationPreferences *self); -CF_EXPORT CFTypeRef _CFApplicationPreferencesCreateValueForKey(_CFApplicationPreferences *prefs, CFStringRef key); -CF_EXPORT void _CFApplicationPreferencesSet(_CFApplicationPreferences *self, CFStringRef defaultName, CFTypeRef value); -CF_EXPORT void _CFApplicationPreferencesRemove(_CFApplicationPreferences *self, CFStringRef defaultName); -CF_EXPORT Boolean _CFApplicationPreferencesSynchronize(_CFApplicationPreferences *self); -CF_EXPORT void _CFApplicationPreferencesUpdate(_CFApplicationPreferences *self); // same as updateDictRep -CF_EXPORT CFDictionaryRef _CFApplicationPreferencesCopyRepresentation3(_CFApplicationPreferences *self, CFDictionaryRef hint, CFDictionaryRef insertion, CFPreferencesDomainRef afterDomain); -CF_EXPORT CFDictionaryRef _CFApplicationPreferencesCopyRepresentationWithHint(_CFApplicationPreferences *self, CFDictionaryRef hint); // same as dictRep -CF_EXPORT void _CFApplicationPreferencesSetStandardSearchList(_CFApplicationPreferences *appPreferences); -CF_EXPORT void _CFApplicationPreferencesSetCacheForApp(_CFApplicationPreferences *appPrefs, CFStringRef appName); -CF_EXPORT void _CFApplicationPreferencesAddSuitePreferences(_CFApplicationPreferences *appPrefs, CFStringRef suiteName); -CF_EXPORT void _CFApplicationPreferencesRemoveSuitePreferences(_CFApplicationPreferences *appPrefs, CFStringRef suiteName); - -CF_EXPORT void _CFApplicationPreferencesAddDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain, Boolean addAtTop); -CF_EXPORT Boolean _CFApplicationPreferencesContainsDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain); -CF_EXPORT void _CFApplicationPreferencesRemoveDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain); - -CF_EXPORT CFTypeRef _CFApplicationPreferencesSearchDownToDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef stopper, CFStringRef key); - - -CF_EXTERN_C_END - - - -// ---- CFString material ---------------------------------------- - -#include - -#define NSSTRING_BOUNDSERROR \ - [NSException raise:NSRangeException format:@"%@: Range or index out of bounds", __CFExceptionProem((id)self, _cmd)] - -#define NSSTRING_RANGEERROR(range, len) \ - [NSException raise:NSRangeException format:@"%@: Range {%lu, %lu} out of bounds; string length %lu", __CFExceptionProem((id)self, _cmd), (unsigned long)range.location, (unsigned long)range.length, (unsigned long)len] - -#define NSSTRING_INDEXERROR(index, len) \ - [NSException raise:NSRangeException format:@"%@: Index %lu out of bounds; string length %lu", __CFExceptionProem((id)self, _cmd), (unsigned long)index, (unsigned long)len] - -// This can be made into an exception for post-10.10 apps -#define NSSTRING_POSSIBLE_RANGEERROR(range, len) \ - if (__CFStringNoteErrors()) { \ - static bool warnonce = false; \ - if (!warnonce) { \ - warnonce = true; \ - CFLog(kCFLogLevelWarning, CFSTR("*** %@: Range {%lu, %lu} out of bounds; string length %lu. This will become an exception for apps linked after 10.10 and iOS 8. Warning shown once per app execution."), __CFExceptionProem((id)self, _cmd), (unsigned long)range.location, (unsigned long)range.length, (unsigned long)len); \ - } \ -} - -#define NSSTRING_ILLEGALREQUESTERROR \ - [NSException raise:NSInvalidArgumentException format:@"Can't call %s in %@", sel_getName(_cmd), object_getClass((id)self)] - -#define NSSTRING_INVALIDMUTATIONERROR \ - [NSException raise:NSInvalidArgumentException format:@"Attempt to mutate immutable object with %s", sel_getName(_cmd)] - -#define NSSTRING_NULLCSTRINGERROR \ - [NSException raise:NSInvalidArgumentException format:@"%@: NULL cString", __CFExceptionProem((id)self, _cmd)] - -#define NSSTRING_NILSTRINGERROR \ - [NSException raise:NSInvalidArgumentException format:@"%@: nil argument", __CFExceptionProem((id)self, _cmd)] - - -CF_EXTERN_C_BEGIN - -/* Create a byte stream from a CFString backing. Can convert a string piece at a - time into a fixed size buffer. Returns number of characters converted. - Characters that cannot be converted to the specified encoding are represented - with the char specified by lossByte; if 0, then lossy conversion is not allowed - and conversion stops, returning partial results. - generatingExternalFile indicates that any extra stuff to allow this data to be - persistent (for instance, BOM) should be included. - Pass buffer==NULL if you don't care about the converted string (but just the - convertability, or number of bytes required, indicated by usedBufLen). - Does not zero-terminate. If you want to create Pascal or C string, allow one - extra byte at start or end. -*/ -CF_EXPORT CFIndex __CFStringEncodeByteStream(CFStringRef string, CFIndex rangeLoc, CFIndex rangeLen, Boolean generatingExternalFile, CFStringEncoding encoding, char lossByte, UInt8 *buffer, CFIndex max, CFIndex *usedBufLen); - -CF_EXPORT CFStringRef __CFStringCreateImmutableFunnel2(CFAllocatorRef alloc, const void *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean possiblyExternalFormat, Boolean tryToReduceUnicode, Boolean hasLengthByte, Boolean hasNullByte, Boolean noCopy, CFAllocatorRef contentsDeallocator); - -CF_EXPORT void __CFStringAppendBytes(CFMutableStringRef str, const char *cStr, CFIndex appendedLength, CFStringEncoding encoding); - -CF_INLINE Boolean __CFStringEncodingIsSupersetOfASCII(CFStringEncoding encoding) { - switch (encoding & 0x0000FF00) { - case 0x0: // MacOS Script range - // Symbol & bidi encodings are not ASCII superset - if (encoding == kCFStringEncodingMacJapanese || encoding == kCFStringEncodingMacArabic || encoding == kCFStringEncodingMacHebrew || encoding == kCFStringEncodingMacUkrainian || encoding == kCFStringEncodingMacSymbol || encoding == kCFStringEncodingMacDingbats) return false; - return true; - - case 0x100: // Unicode range - if (encoding != kCFStringEncodingUTF8) return false; - return true; - - case 0x200: // ISO range - if (encoding == kCFStringEncodingISOLatinArabic) return false; - return true; - - case 0x600: // National standards range - if (encoding != kCFStringEncodingASCII) return false; - return true; - - case 0x800: // ISO 2022 range - return false; // It's modal encoding - - case 0xA00: // Misc standard range - if ((encoding == kCFStringEncodingShiftJIS) || (encoding == kCFStringEncodingHZ_GB_2312) || (encoding == kCFStringEncodingUTF7_IMAP)) return false; - return true; - - case 0xB00: - if (encoding == kCFStringEncodingNonLossyASCII) return false; - return true; - - case 0xC00: // EBCDIC - return false; - - default: - return ((encoding & 0x0000FF00) > 0x0C00 ? false : true); - } -} - - -/* Desperately using extern here */ -CF_EXPORT CFStringEncoding __CFDefaultEightBitStringEncoding; -CF_EXPORT CFStringEncoding __CFStringComputeEightBitStringEncoding(void); - -CF_INLINE CFStringEncoding __CFStringGetEightBitStringEncoding(void) { - if (__CFDefaultEightBitStringEncoding == kCFStringEncodingInvalidId) __CFStringComputeEightBitStringEncoding(); - return __CFDefaultEightBitStringEncoding; -} - -enum { - __kCFVarWidthLocalBufferSize = 1008 -}; - -typedef struct { /* A simple struct to maintain ASCII/Unicode versions of the same buffer. */ - union { - UInt8 *ascii; - UniChar *unicode; - } chars; - Boolean isASCII; /* This really does mean 7-bit ASCII, not _NSDefaultCStringEncoding() */ - Boolean shouldFreeChars; /* If the number of bytes exceeds __kCFVarWidthLocalBufferSize, bytes are allocated */ - Boolean _unused1; - Boolean _unused2; - CFAllocatorRef allocator; /* Use this allocator to allocate, reallocate, and deallocate the bytes */ - CFIndex numChars; /* This is in terms of ascii or unicode; that is, if isASCII, it is number of 7-bit chars; otherwise it is number of UniChars; note that the actual allocated space might be larger */ - UInt8 localBuffer[__kCFVarWidthLocalBufferSize]; /* private; 168 ISO2022JP chars, 504 Unicode chars, 1008 ASCII chars */ -} CFVarWidthCharBuffer; - - -/* Convert a byte stream to ASCII (7-bit!) or Unicode, with a CFVarWidthCharBuffer struct on the stack. false return indicates an error occured during the conversion. Depending on .isASCII, follow .chars.ascii or .chars.unicode. If .shouldFreeChars is returned as true, free the returned buffer when done with it. If useClientsMemoryPtr is provided as non-NULL, and the provided memory can be used as is, this is set to true, and the .ascii or .unicode buffer in CFVarWidthCharBuffer is set to bytes. -!!! If the stream is Unicode and has no BOM, the data is assumed to be big endian! Could be trouble on Intel if someone didn't follow that assumption. -!!! __CFStringDecodeByteStream2() needs to be deprecated and removed post-Jaguar. -*/ -CF_EXPORT Boolean __CFStringDecodeByteStream2(const UInt8 *bytes, UInt32 len, CFStringEncoding encoding, Boolean alwaysUnicode, CFVarWidthCharBuffer *buffer, Boolean *useClientsMemoryPtr); -CF_EXPORT Boolean __CFStringDecodeByteStream3(const UInt8 *bytes, CFIndex len, CFStringEncoding encoding, Boolean alwaysUnicode, CFVarWidthCharBuffer *buffer, Boolean *useClientsMemoryPtr, UInt32 converterFlags); - - -/* Convert single byte to Unicode; assumes one-to-one correspondence (that is, can only be used with 1-byte encodings). You can use the function if it's not NULL. -*/ -CF_EXPORT Boolean (*__CFCharToUniCharFunc)(UInt32 flags, UInt8 ch, UniChar *unicodeChar); - -/* Character class functions UnicodeData-2_1_5.txt -*/ -CF_INLINE Boolean __CFIsWhitespace(UniChar theChar) { - return ((theChar < 0x21) || (theChar > 0x7E && theChar < 0xA1) || (theChar >= 0x2000 && theChar <= 0x200B) || (theChar == 0x3000)) ? true : false; -} - -/* Same as CFStringGetCharacterFromInlineBuffer() but returns 0xFFFF on out of bounds access -*/ -CF_INLINE UniChar __CFStringGetCharacterFromInlineBufferAux(CFStringInlineBuffer *buf, CFIndex idx) { - if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0xFFFF; - if (buf->directUniCharBuffer) return buf->directUniCharBuffer[idx + buf->rangeToBuffer.location]; - if (buf->directCStringBuffer) return (UniChar)(buf->directCStringBuffer[idx + buf->rangeToBuffer.location]); - if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) { - if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0; - buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength; - if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length; - CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer); - } - return buf->buffer[idx - buf->bufferedRangeStart]; -} - -/* Same as CFStringGetCharacterFromInlineBuffer(), but without the bounds checking (will return garbage or crash) -*/ -CF_INLINE UniChar __CFStringGetCharacterFromInlineBufferQuick(CFStringInlineBuffer *buf, CFIndex idx) { - if (buf->directUniCharBuffer) return buf->directUniCharBuffer[idx + buf->rangeToBuffer.location]; - if (buf->directCStringBuffer) return (UniChar)(buf->directCStringBuffer[idx + buf->rangeToBuffer.location]); - if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) { - if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0; - buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength; - if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length; - CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer); - } - return buf->buffer[idx - buf->bufferedRangeStart]; -} - - -/* These two allow specifying an alternate description function (instead of CFCopyDescription); used by NSString -*/ -CF_EXPORT void _CFStringAppendFormatAndArgumentsAux(CFMutableStringRef outputString, CFStringRef (*copyDescFunc)(void *, const void *loc), CFDictionaryRef formatOptions, CFStringRef formatString, va_list args); -CF_EXPORT CFStringRef _CFStringCreateWithFormatAndArgumentsAux(CFAllocatorRef alloc, CFStringRef (*copyDescFunc)(void *, const void *loc), CFDictionaryRef formatOptions, CFStringRef format, va_list arguments); - -CF_EXPORT void _CFStringAppendFormatAndArgumentsAux2(CFMutableStringRef outputString, CFStringRef (*copyDescFunc)(void *, const void *loc), CFStringRef (*contextDescFunc)(void *, const void *, const void *, bool, bool *), CFDictionaryRef formatOptions, CFStringRef formatString, va_list args); -CF_EXPORT CFStringRef _CFStringCreateWithFormatAndArgumentsAux2(CFAllocatorRef alloc, CFStringRef (*copyDescFunc)(void *, const void *loc), CFStringRef (*contextDescFunc)(void *, const void *, const void *, bool, bool *), CFDictionaryRef formatOptions, CFStringRef format, va_list arguments); - -/* For NSString (and NSAttributedString) usage, mutate with isMutable check -*/ -enum {_CFStringErrNone = 0, _CFStringErrNotMutable = 1, _CFStringErrNilArg = 2, _CFStringErrBounds = 3}; -CF_EXPORT int __CFStringCheckAndReplace(CFMutableStringRef str, CFRange range, CFStringRef replacement); -CF_EXPORT Boolean __CFStringNoteErrors(void); // Should string errors raise? - -/* For NSString usage, guarantees that the contents can be extracted as 8-bit bytes in the __CFStringGetEightBitStringEncoding(). -*/ -CF_EXPORT Boolean __CFStringIsEightBit(CFStringRef str); - -/* For NSCFString usage, these do range check (where applicable) but don't check for ObjC dispatch -*/ -CF_EXPORT int _CFStringCheckAndGetCharacterAtIndex(CFStringRef str, CFIndex idx, UniChar *ch); -CF_EXPORT int _CFStringCheckAndGetCharacters(CFStringRef str, CFRange range, UniChar *buffer); -CF_EXPORT CFIndex _CFStringGetLength2(CFStringRef str); -CF_EXPORT CFHashCode __CFStringHash(CFTypeRef cf); -CF_EXPORT CFHashCode CFStringHashISOLatin1CString(const uint8_t *bytes, CFIndex len); -CF_EXPORT CFHashCode CFStringHashCString(const uint8_t *bytes, CFIndex len); -CF_EXPORT CFHashCode CFStringHashCharacters(const UniChar *characters, CFIndex len); -CF_EXPORT CFHashCode CFStringHashNSString(CFStringRef str); - - -CF_EXTERN_C_END - - -// ---- Binary plist material ---------------------------------------- - -typedef const struct __CFKeyedArchiverUID * CFKeyedArchiverUIDRef; -CF_EXPORT CFTypeID _CFKeyedArchiverUIDGetTypeID(void); -CF_EXPORT CFKeyedArchiverUIDRef _CFKeyedArchiverUIDCreate(CFAllocatorRef allocator, uint32_t value); -CF_EXPORT uint32_t _CFKeyedArchiverUIDGetValue(CFKeyedArchiverUIDRef uid); - - -enum { - kCFBinaryPlistMarkerNull = 0x00, - kCFBinaryPlistMarkerFalse = 0x08, - kCFBinaryPlistMarkerTrue = 0x09, - kCFBinaryPlistMarkerFill = 0x0F, - kCFBinaryPlistMarkerInt = 0x10, - kCFBinaryPlistMarkerReal = 0x20, - kCFBinaryPlistMarkerDate = 0x33, - kCFBinaryPlistMarkerData = 0x40, - kCFBinaryPlistMarkerASCIIString = 0x50, - kCFBinaryPlistMarkerUnicode16String = 0x60, - kCFBinaryPlistMarkerUID = 0x80, - kCFBinaryPlistMarkerArray = 0xA0, - kCFBinaryPlistMarkerSet = 0xC0, - kCFBinaryPlistMarkerDict = 0xD0 -}; - -typedef struct { - uint8_t _magic[6]; - uint8_t _version[2]; -} CFBinaryPlistHeader; - -typedef struct { - uint8_t _unused[5]; - uint8_t _sortVersion; - uint8_t _offsetIntSize; - uint8_t _objectRefSize; - uint64_t _numObjects; - uint64_t _topObject; - uint64_t _offsetTableOffset; -} CFBinaryPlistTrailer; - - -CF_EXPORT bool __CFBinaryPlistGetTopLevelInfo(const uint8_t *databytes, uint64_t datalen, uint8_t *marker, uint64_t *offset, CFBinaryPlistTrailer *trailer); -CF_EXPORT bool __CFBinaryPlistGetOffsetForValueFromArray2(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFIndex idx, uint64_t *offset, CFMutableDictionaryRef objects); -CF_EXPORT bool __CFBinaryPlistGetOffsetForValueFromDictionary3(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFTypeRef key, uint64_t *koffset, uint64_t *voffset, Boolean unused, CFMutableDictionaryRef objects); -CF_EXPORT bool __CFBinaryPlistCreateObject(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFAllocatorRef allocator, CFOptionFlags mutabilityOption, CFMutableDictionaryRef objects, CFPropertyListRef *plist); -CF_EXPORT CFIndex __CFBinaryPlistWriteToStream(CFPropertyListRef plist, CFTypeRef stream); -CF_EXPORT CFIndex __CFBinaryPlistWriteToStreamWithEstimate(CFPropertyListRef plist, CFTypeRef stream, uint64_t estimate); // will be removed soon -CF_EXPORT CFIndex __CFBinaryPlistWriteToStreamWithOptions(CFPropertyListRef plist, CFTypeRef stream, uint64_t estimate, CFOptionFlags options); // will be removed soon -CF_EXPORT CFIndex __CFBinaryPlistWrite(CFPropertyListRef plist, CFTypeRef stream, uint64_t estimate, CFOptionFlags options, CFErrorRef *error); - -// ---- Used by property list parsing in Foundation - -CF_EXPORT CFTypeRef _CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags option, CFStringRef *errorString, Boolean allowNewTypes, CFPropertyListFormat *format); - -CF_EXPORT CFTypeRef _CFPropertyListCreateFromXMLString(CFAllocatorRef allocator, CFStringRef xmlString, CFOptionFlags option, CFStringRef *errorString, Boolean allowNewTypes, CFPropertyListFormat *format); - -// ---- Sudden Termination material ---------------------------------------- - -#if DEPLOYMENT_TARGET_MACOSX - -CF_EXPORT void _CFSuddenTerminationDisable(void); -CF_EXPORT void _CFSuddenTerminationEnable(void); -CF_EXPORT void _CFSuddenTerminationExitIfTerminationEnabled(int exitStatus); -CF_EXPORT void _CFSuddenTerminationExitWhenTerminationEnabled(int exitStatus); -CF_EXPORT size_t _CFSuddenTerminationDisablingCount(void); - -#endif - -// ---- Thread-specific data -------------------------------------------- - -// Get some thread specific data from a pre-assigned slot. -CF_EXPORT void *_CFGetTSD(uint32_t slot); - -// Set some thread specific data in a pre-assigned slot. Don't pick a random value. Make sure you're using a slot that is unique. Pass in a destructor to free this data, or NULL if none is needed. Unlike pthread TSD, the destructor is per-thread. -CF_EXPORT void *_CFSetTSD(uint32_t slot, void *newVal, void (*destructor)(void *)); - -#if DEPLOYMENT_TARGET_WINDOWS -// ---- Windows-specific material --------------------------------------- - -// These are replacements for POSIX calls on Windows, ensuring that the UTF8 parameters are converted to UTF16 before being passed to Windows -CF_EXPORT int _NS_stat(const char *name, struct _stat *st); -CF_EXPORT int _NS_mkdir(const char *name); -CF_EXPORT int _NS_rmdir(const char *name); -CF_EXPORT int _NS_chmod(const char *name, int mode); -CF_EXPORT int _NS_unlink(const char *name); -CF_EXPORT char *_NS_getcwd(char *dstbuf, size_t size); // Warning: this doesn't support dstbuf as null even though 'getcwd' does -CF_EXPORT char *_NS_getenv(const char *name); -CF_EXPORT int _NS_rename(const char *oldName, const char *newName); -CF_EXPORT int _NS_open(const char *name, int oflag, int pmode); -CF_EXPORT int _NS_mkstemp(char *name, int bufSize); -#endif - -// ---- Miscellaneous material ---------------------------------------- - -#include -#include -#include - -CF_EXTERN_C_BEGIN - -CF_EXPORT CFTypeID CFTypeGetTypeID(void); - -CF_EXPORT void _CFArraySetCapacity(CFMutableArrayRef array, CFIndex cap); -CF_EXPORT void _CFBagSetCapacity(CFMutableBagRef bag, CFIndex cap); -CF_EXPORT void _CFDictionarySetCapacity(CFMutableDictionaryRef dict, CFIndex cap); -CF_EXPORT void _CFSetSetCapacity(CFMutableSetRef set, CFIndex cap); - -CF_EXPORT void CFCharacterSetCompact(CFMutableCharacterSetRef theSet); -CF_EXPORT void CFCharacterSetFast(CFMutableCharacterSetRef theSet); - -CF_EXPORT const void *_CFArrayCheckAndGetValueAtIndex(CFArrayRef array, CFIndex idx); -CF_EXPORT void _CFArrayReplaceValues(CFMutableArrayRef array, CFRange range, const void **newValues, CFIndex newCount); - - -/* Enumeration - Call CFStartSearchPathEnumeration() once, then call - CFGetNextSearchPathEnumeration() one or more times with the returned state. - The return value of CFGetNextSearchPathEnumeration() should be used as - the state next time around. - When CFGetNextSearchPathEnumeration() returns 0, you're done. -*/ -typedef CFIndex CFSearchPathEnumerationState; -CF_EXPORT CFSearchPathEnumerationState __CFStartSearchPathEnumeration(CFSearchPathDirectory dir, CFSearchPathDomainMask domainMask); -CF_EXPORT CFSearchPathEnumerationState __CFGetNextSearchPathEnumeration(CFSearchPathEnumerationState state, UInt8 *path, CFIndex pathSize); - -/* For use by NSNumber and CFNumber. - Hashing algorithm for CFNumber: - M = Max CFHashCode (assumed to be unsigned) - For positive integral values: (N * HASHFACTOR) mod M - For negative integral values: ((-N) * HASHFACTOR) mod M - For floating point numbers that are not integral: hash(integral part) + hash(float part * M) - HASHFACTOR is 2654435761, from Knuth's multiplicative method -*/ -#define HASHFACTOR 2654435761U - -CF_INLINE CFHashCode _CFHashInt(long i) { - return ((i > 0) ? (CFHashCode)(i) : (CFHashCode)(-i)) * HASHFACTOR; -} - -CF_INLINE CFHashCode _CFHashDouble(double d) { - double dInt; - if (d < 0) d = -d; - dInt = floor(d+0.5); - CFHashCode integralHash = HASHFACTOR * (CFHashCode)fmod(dInt, (double)ULONG_MAX); - return (CFHashCode)(integralHash + (CFHashCode)((d - dInt) * ULONG_MAX)); -} - - -/* These four functions are used by NSError in formatting error descriptions. They take NS or CFError as arguments and return a retained CFString or NULL. -*/ -CF_EXPORT CFStringRef _CFErrorCreateLocalizedDescription(CFErrorRef err); -CF_EXPORT CFStringRef _CFErrorCreateLocalizedFailureReason(CFErrorRef err); -CF_EXPORT CFStringRef _CFErrorCreateLocalizedRecoverySuggestion(CFErrorRef err); -CF_EXPORT CFStringRef _CFErrorCreateDebugDescription(CFErrorRef err); - -CF_EXPORT void *__CFURLReservedPtr(CFURLRef url); -CF_EXPORT void __CFURLSetReservedPtr(CFURLRef url, void *ptr); -CF_EXPORT CFStringEncoding _CFURLGetEncoding(CFURLRef url); - -#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI || DEPLOYMENT_TARGET_WINDOWS -CF_EXPORT Boolean _CFRunLoopFinished(CFRunLoopRef rl, CFStringRef mode); -#endif - -CF_EXPORT CFIndex _CFStreamInstanceSize(void); - -#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED -typedef struct { - mach_vm_address_t address; - mach_vm_size_t size; - mach_port_t port; - bool purgeable; - bool corporeal; - bool volatyle; - uintptr_t reserved; -} CFDiscorporateMemory; - -extern kern_return_t _CFDiscorporateMemoryAllocate(CFDiscorporateMemory *hm, size_t size, bool purgeable); -extern kern_return_t _CFDiscorporateMemoryDeallocate(CFDiscorporateMemory *hm); -extern kern_return_t _CFDiscorporateMemoryDematerialize(CFDiscorporateMemory *hm); -extern kern_return_t _CFDiscorporateMemoryMaterialize(CFDiscorporateMemory *hm); -#endif - -enum { - kCFNumberFormatterOrdinalStyle = 6, - kCFNumberFormatterDurationStyle = 7, -}; - -// This is for NSNumberFormatter use only! -CF_EXPORT void *_CFNumberFormatterGetFormatter(CFNumberFormatterRef formatter); - -CF_EXPORT CFRange _CFDataFindBytes(CFDataRef data, CFDataRef dataToFind, CFRange searchRange, CFDataSearchFlags compareOptions); - - -#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI - #if !defined(__CFReadTSR) - #include - #define __CFReadTSR() mach_absolute_time() - #endif -#elif DEPLOYMENT_TARGET_WINDOWS -#if 0 -CF_INLINE UInt64 __CFReadTSR(void) { - LARGE_INTEGER freq; - QueryPerformanceCounter(&freq); - return freq.QuadPart; -} -#endif -#endif - - -CF_EXTERN_C_END - -#ifdef __OBJC__ -#import - -extern id _objc_rootAutorelease(id obj); - -static inline id ___CFAllocateObject2(Class cls, size_t extraBytes) { - id obj = class_createInstance(cls, extraBytes); - if (obj == NULL) { - // Good luck: it couldnt allocate room for one measly object, yet this is going to allocate atleast 2 (and probably a few more underneath) - CFStringRef reason = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("Could not allocate class %s"), class_getName(cls)); - reason = (CFStringRef)_objc_rootAutorelease((id)reason); - @throw [NSException exceptionWithName:NSMallocException reason:(NSString *)reason userInfo:NULL]; - } - return obj; -} - -static inline id ___CFAllocateObject(Class cls) { - return ___CFAllocateObject2(cls, 0); -} - -@interface NSCalendar (CoreFoundation) -- (CFRange)_minimumRangeOfUnit:(CFCalendarUnit)unit; -- (CFRange)_maximumRangeOfUnit:(CFCalendarUnit)unit; -- (CFRange)_rangeOfUnit:(CFCalendarUnit)smallerUnit inUnit:(CFCalendarUnit)biggerUnit forAT:(CFAbsoluteTime)at; -@end - -@interface NSStream (CoreFoundation) -- (CFStreamError)_cfStreamError; -- (void)_unscheduleFromCFRunLoop:(CFRunLoopRef)runLoop forMode:(CFStringRef)mode; -- (void)_scheduleInCFRunLoop:(CFRunLoopRef)runLoop forMode:(CFStringRef)mode; -@end - -@interface NSInputStream (CoreFoundation) -- (BOOL)_setCFClientFlags:(CFOptionFlags)flags callback:(CFReadStreamClientCallBack)callback context:(CFStreamClientContext *)context; -@end - -@interface NSOutputStream (CoreFoundation) -- (BOOL)_setCFClientFlags:(CFOptionFlags)flags callback:(CFWriteStreamClientCallBack)callback context:(CFStreamClientContext *)context; -@end - -@interface NSTimer (CoreFoundation) -- (CFAbsoluteTime)_cffireTime; -@end - -@interface NSTimeZone (CoreFoundation) -- (double)_daylightSavingTimeOffsetForAbsoluteTime:(double)at; -- (double)_nextDaylightSavingTimeTransitionAfterAbsoluteTime:(double)at; -@end - - -#endif - -#endif /* ! __COREFOUNDATION_FORFOUNDATIONONLY__ */ - diff --git a/ForFoundationOnly.h b/ForFoundationOnly.h new file mode 120000 index 0000000..0b8b306 --- /dev/null +++ b/ForFoundationOnly.h @@ -0,0 +1 @@ +include/CoreFoundation/./ForFoundationOnly.h \ No newline at end of file diff --git a/FoundationExceptions.h b/FoundationExceptions.h deleted file mode 100644 index 5ee41c6..0000000 --- a/FoundationExceptions.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (C) 2017 Lubos Dolezel - * - * Darling is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Foobar is distributed in the hope that it will be useful, - * Darling WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - -#ifndef _FOUNDATION_EXCEPTIONS_H -#define _FOUNDATION_EXCEPTIONS_H - -#if !__OBJC2__ - -enum { - kCFDoExceptionOperationGetUncaughtHandler = 0, - kCFDoExceptionOperationSetUncaughtHandler, - kCFDoExceptionOperationRaiseError = 40, - kCFDoExceptionOperationAddHandler = 50, - kCFDoExceptionOperationRemoveHandler, - kCFDoExceptionOperationExtractException -}; - -void* _CFDoExceptionOperation(int op, void* arg); - -__attribute__((visibility("hidden"))) -void __exceptionInit(void); - -#endif - -#endif diff --git a/FoundationExceptions.h b/FoundationExceptions.h new file mode 120000 index 0000000..7b01fd4 --- /dev/null +++ b/FoundationExceptions.h @@ -0,0 +1 @@ +include/CoreFoundation/./FoundationExceptions.h \ No newline at end of file diff --git a/GNUstep.h b/GNUstep.h deleted file mode 100644 index ea8ea88..0000000 --- a/GNUstep.h +++ /dev/null @@ -1,79 +0,0 @@ -/* GNUstep.h - macros to make easier to port gnustep apps to macos-x - Copyright (C) 2001 Free Software Foundation, Inc. - - Written by: Nicola Pero - Date: March, October 2001 - - This file is part of GNUstep. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef __GNUSTEP_GNUSTEP_H_INCLUDED_ -#define __GNUSTEP_GNUSTEP_H_INCLUDED_ - -#ifndef GNUSTEP - -#define AUTORELEASE(object) [object autorelease] -#define TEST_AUTORELEASE(object) ({ if (object) [object autorelease]; }) - -#define RELEASE(object) [object release] -#define TEST_RELEASE(object) ({ if (object) [object release]; }) - -#define RETAIN(object) [object retain] -#define TEST_RETAIN(object) ({ if (object) [object retain]; }) - -#define ASSIGN(object,value) ({\ - id __value = (id)(value); \ - id __object = (id)(object); \ - if (__value != __object) \ - { \ - if (__value != nil) \ - { \ - [__value retain]; \ - } \ - object = __value; \ - if (__object != nil) \ - { \ - [__object release]; \ - } \ - } \ - }) - -#define ASSIGNCOPY(object,value) ASSIGN(object, [[value copy] autorelease]); - -#define DESTROY(object) ({ \ - if (object) \ - { \ - id __o = object; \ - object = nil; \ - [__o release]; \ - } \ - }) - -#define CREATE_AUTORELEASE_POOL(X) \ -NSAutoreleasePool *(X) = [NSAutoreleasePool new] - -#define NSLocalizedString(key, comment) \ - [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil] - -#define _(X) NSLocalizedString (X, nil) -#define __(X) X - -#define NSLocalizedStaticString(X, Y) X - -#endif /* GNUSTEP */ - -#endif /* __GNUSTEP_GNUSTEP_H_INCLUDED_ */ diff --git a/GNUstep.h b/GNUstep.h new file mode 120000 index 0000000..1b0304d --- /dev/null +++ b/GNUstep.h @@ -0,0 +1 @@ +include/CoreFoundation/./GNUstep.h \ No newline at end of file diff --git a/GSInvocation.h b/GSInvocation.h deleted file mode 100644 index 785b015..0000000 --- a/GSInvocation.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Interface for NSInvocation concrete classes for GNUStep - Copyright (C) 1998 Free Software Foundation, Inc. - - Written: Adam Fedor - Date: Nov 2000 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. - */ - -#ifndef __GSInvocation_h_GNUSTEP_BASE_INCLUDE -#define __GSInvocation_h_GNUSTEP_BASE_INCLUDE - -#include - -@class NSMutableData; - -typedef struct { - int offset; - unsigned size; - const char *type; - const char *qtype; - unsigned align; - unsigned qual; - BOOL isReg; -} NSArgumentInfo; - - -@interface GSFFIInvocation : NSInvocation -{ -@public - uint8_t _retbuf[32]; // Store return values of up to 32 bytes here. - NSMutableData *_frame; -} -@end - -@interface GSFFCallInvocation : NSInvocation -{ -} -@end - -@interface GSDummyInvocation : NSInvocation -{ -} -@end - -@interface NSInvocation (DistantCoding) -- (BOOL) encodeWithDistantCoder: (NSCoder*)coder passPointers: (BOOL)passp; -@end - -@interface NSMethodSignature (GNUstep) -- (const char*) methodType; -- (NSArgumentInfo*) methodInfo; -@end - -extern void -GSFFCallInvokeWithTargetAndImp(NSInvocation *inv, id anObject, IMP imp); - -extern void -GSFFIInvokeWithTargetAndImp(NSInvocation *inv, id anObject, IMP imp); - -#define CLEAR_RETURN_VALUE_IF_OBJECT \ -do {\ - if (_validReturn && *_inf[0].type == _C_ID) \ - { \ - RELEASE (*(id*) _retval); \ - *(id*) _retval = nil; \ - _validReturn = NO; \ - }\ - } while (0) - -#define RETAIN_RETURN_VALUE do { if (*_inf[0].type == _C_ID) RETAIN (*(id*) _retval);} while (0) - -#define _inf ((NSArgumentInfo*)_info) - -#endif diff --git a/GSInvocation.h b/GSInvocation.h new file mode 120000 index 0000000..dfef2af --- /dev/null +++ b/GSInvocation.h @@ -0,0 +1 @@ +include/CoreFoundation/./GSInvocation.h \ No newline at end of file diff --git a/GSObjCRuntime.h b/GSObjCRuntime.h deleted file mode 100644 index 3aa0746..0000000 --- a/GSObjCRuntime.h +++ /dev/null @@ -1,629 +0,0 @@ -/** Interface to ObjC runtime for GNUStep - Copyright (C) 1995, 1997, 2000, 2002, 2003 Free Software Foundation, Inc. - - Written by: Andrew Kachites McCallum - Date: 1995 - Written by: Richard Frith-Macdonald - Date: 2002 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. - - AutogsdocSource: Additions/GSObjCRuntime.m - - */ - -#ifndef __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE -#define __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE - -#include - -#define __GNU_LIBOBJC__ -#define OBJC2RUNTIME 1 -#ifndef GS_EXPORT -# define GS_EXPORT extern -#endif - -#if NeXT_RUNTIME - #include - #include - #include - #ifndef _C_ATOM - #define _C_ATOM '%' - #endif - #define _F_CONST 0x01 - #define _F_IN 0x01 - #define _F_OUT 0x02 - #define _F_INOUT 0x03 - #define _F_BYCOPY 0x04 - #define _F_ONEWAY 0x08 - #define _C_CONST 'r' - #define _C_IN 'n' - #define _C_INOUT 'N' - #define _C_OUT 'o' - #define _C_BYCOPY 'O' - #define _C_ONEWAY 'V' -#else /* GNU Objective C Runtime */ - #include - #if defined (__GNU_LIBOBJC__) - #include - #else - #include - #include - #endif -#endif - -/* - * Hack for older compiler versions that don't have all defines - * needed in objc-api.h - */ -#ifndef _C_LNG_LNG -#define _C_LNG_LNG 'q' -#endif -#ifndef _C_ULNG_LNG -#define _C_ULNG_LNG 'Q' -#endif - -#if OBJC2RUNTIME -/* We have a real ObjC2 runtime. - */ -#include -#else -/* We emulate an ObjC2 runtime. - */ -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -@class NSArray; -@class NSDictionary; -@class NSObject; -@class NSString; -@class NSValue; - -#ifndef YES -#define YES 1 -#endif -#ifndef NO -#define NO 0 -#endif -#ifndef nil -#define nil 0 -#endif - -#if !defined(_C_CONST) -#define _C_CONST 'r' -#endif -#if !defined(_C_IN) -#define _C_IN 'n' -#endif -#if !defined(_C_INOUT) -#define _C_INOUT 'N' -#endif -#if !defined(_C_OUT) -#define _C_OUT 'o' -#endif -#if !defined(_C_BYCOPY) -#define _C_BYCOPY 'O' -#endif -#if !defined(_C_BYREF) -#define _C_BYREF 'R' -#endif -#if !defined(_C_ONEWAY) -#define _C_ONEWAY 'V' -#endif -#if !defined(_C_GCINVISIBLE) -#define _C_GCINVISIBLE '!' -#endif - -/* - * Functions for accessing instance variables directly - - * We can copy an ivar into arbitrary data, - * Get the type encoding for a named ivar, - * and copy a value into an ivar. - */ -GS_EXPORT BOOL -GSObjCFindVariable(id obj, const char *name, - const char **type, unsigned int *size, int *offset); - -GS_EXPORT void -GSObjCGetVariable(id obj, int offset, unsigned int size, void *data); - -GS_EXPORT void -GSObjCSetVariable(id obj, int offset, unsigned int size, const void *data); - -GS_EXPORT NSArray * -GSObjCMethodNames(id obj, BOOL recurse); - -GS_EXPORT NSArray * -GSObjCVariableNames(id obj, BOOL recurse); - -/** - *

A Behavior can be seen as a "Protocol with an implementation" or a - * "Class without any instance variables". A key feature of behaviors - * is that they give a degree of multiple inheritance. - *

- *

Behavior methods, when added to a class, override the class's - * superclass methods, but not the class's methods. - *

- *

Whan a behavior class is added to a receiver class, not only are the - * methods defined in the behavior class added, but the methods from the - * behavior's class hierarchy are also added (unless already present). - *

- *

It's not the case that a class adding behaviors from another class - * must have "no instance vars". The receiver class just has to have the - * same layout as the behavior class (optionally with some additional - * ivars after those of the behavior class). - *

- *

This function provides Behaviors without adding any new syntax to - * the Objective C language. Simply define a class with the methods you - * want to add, then call this function with that class as the behavior - * argument. - *

- *

This function should be called in the +initialize method of the receiver. - *

- *

If you add several behaviors to a class, be aware that the order of - * the additions is significant. - *

- */ -GS_EXPORT void -GSObjCAddClassBehavior(Class receiver, Class behavior); - -/** - *

An Override can be seen as a "category implemented as a separate class - * and manually added to the receiver class under program control, rather - * than automatically added by the compiler/runtime. - *

- *

Override methods, when added to a receiver class, replace the class's - * class's methods of the same name (or are added if the class did not define - * methods with that name). - *

- *

It's not the case that a class adding overrides from another class - * must have "no instance vars". The receiver class just has to have the - * same layout as the override class (optionally with some additional - * ivars after those of the override class). - *

- *

This function provides overrides without adding any new syntax to - * the Objective C language. Simply define a class with the methods you - * want to add, then call this function with that class as the override - * argument. - *

- *

This function should usually be called in the +initialize method - * of the receiver. - *

- *

If you add several overrides to a class, be aware that the order of - * the additions is significant. - *

- */ -GS_EXPORT void -GSObjCAddClassOverride(Class receiver, Class override); - -/** Turn on (YES), off (NO) or test (-1) behavior debugging. - */ -GS_EXPORT BOOL GSObjCBehaviorDebug(int setget); - -GS_EXPORT NSValue * -GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars); - -GS_EXPORT void -GSObjCAddClasses(NSArray *classes); - -/** - * Given a NULL terminated list of methods, add them to the class.
- * If the method already exists in a superclass, the new version overrides - * that one, but if the method already exists in the class itsself, the - * new one is quietly ignored (replace==NO) or replaced with the new - * version (if replace==YES).
- * To add class methods, cls should be the metaclass of the class to - * which the methods are being added. - */ -GS_EXPORT void -GSObjCAddMethods(Class cls, Method *list, BOOL replace); - -/* - * Functions for key-value encoding ... they access values in an object - * either by selector or directly, but do so using NSNumber for the - * scalar types of data. - */ -GS_EXPORT id -GSObjCGetVal(NSObject *self, const char *key, SEL sel, - const char *type, unsigned size, int offset); - -GS_EXPORT void -GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel, - const char *type, unsigned size, int offset); - -/* - * This section includes runtime functions - * to query and manipulate the ObjC runtime structures. - * These functions take care to not use ObjC code so - * that they can safely be used in +(void)load implementations - * where applicable. - */ - -/** - * Deprecated ... use objc_getClassList() - */ -GS_EXPORT unsigned int -GSClassList(Class *buffer, unsigned int max, BOOL clearCache); - -/** - * GSObjCClass() is deprecated ... use object_getClass() - */ -GS_EXPORT Class GSObjCClass(id obj); - -/** - * GSObjCSuper() is deprecated ... use class_getSuperclass() - */ -GS_EXPORT Class GSObjCSuper(Class cls); - -/** - * GSObjCIsInstance() is deprecated ... use object_getClass() - * in conjunction with class_isMetaClass() - */ -GS_EXPORT BOOL GSObjCIsInstance(id obj); - -/** - * GSObjCIsClass() is deprecated ... use object_getClass() - * in conjunction with class_isMetaClass() - */ -GS_EXPORT BOOL GSObjCIsClass(Class cls); - -/** - * Test to see if class inherits from another class - * The argument to this function must NOT be nil. - */ -GS_EXPORT BOOL GSObjCIsKindOf(Class cls, Class other); - -/** - * GSClassFromName() is deprecated ... use objc_lookUpClass() - */ -GS_EXPORT Class GSClassFromName(const char *name); - -/** - * GSNameFromClass() is deprecated ... use class_getName() - */ -GS_EXPORT const char *GSNameFromClass(Class cls); - -/** - * GSClassNameFromObject() is deprecated ... use object_getClass() - * in conjunction with class_getName() - */ -GS_EXPORT const char *GSClassNameFromObject(id obj); - -/** - * GSNameFromSelector() is deprecated ... use sel_getName() - */ -GS_EXPORT const char *GSNameFromSelector(SEL sel); - -/** - * GSSelectorFromName() is deprecated ... use sel_getUid() - */ -GS_EXPORT SEL -GSSelectorFromName(const char *name); - -/** - * Return the selector for the specified name and types.
- * Returns a nul pointer if the name is nul.
- * Creates a new selector if necessary.
- * Code must NOT rely on this providing a selector with type information. - */ -GS_EXPORT SEL -GSSelectorFromNameAndTypes(const char *name, const char *types); - -/** - * Return the type information from the specified selector.
- * May return a nul pointer if the selector was a nul pointer or if it - * was not typed (or if the runtime does not support typed selectors).
- * Code must NOT rely on this providing any type information. - */ -GS_EXPORT const char * -GSTypesFromSelector(SEL sel); - -/** - * Compare only the type information ignoring qualifiers, the frame layout - * and register markers. Unlike sel_types_match, this function also - * handles comparisons of types with and without any layout information. - */ -GS_EXPORT BOOL -GSSelectorTypesMatch(const char *types1, const char *types2); - -/** Takes full type information and skips forward to the actual type - * as specified in the _C_... constants. - */ -GS_EXPORT const char * -GSSkipTypeQualifierAndLayoutInfo(const char *types); - -/** - * Returns a protocol object with the corresponding name. - * This function searches the registered classes for any protocol - * with the supplied name. If one is found, it is cached in - * for future requests. If efficiency is a factor then use - * GSRegisterProtocol() to insert a protocol explicitly into the cache - * used by this function. If no protocol is found this function returns - * nil. - */ -GS_EXPORT Protocol * -GSProtocolFromName(const char *name); - -/** - * Registers proto in the cache used by GSProtocolFromName(). - */ -GS_EXPORT void -GSRegisterProtocol(Protocol *proto); - -/** - * A variant of protocol_getMethodDescription which recursively searches - * parent protocols if the requested selector isn't found in the given - * protocol. - * - * Returns a {NULL, NULL} structure if the requested selector couldn't be - * found. - */ -GS_EXPORT struct objc_method_description -GSProtocolGetMethodDescriptionRecursive(Protocol *aProtocol, SEL aSel, BOOL isRequired, BOOL isInstance); - -/* - * Unfortunately the definition of the symbols - * 'Method(_t)', 'MethodList(_t)' and 'IVar(_t)' - * are incompatible between the GNU and NeXT/Apple runtimes. - * We introduce GSMethod, GSMethodList and GSIVar to allow portability. - */ -typedef Method GSMethod; -typedef Ivar GSIVar; - -/** - * Returns the pointer to the method structure - * for the selector in the specified class. - * Depending on searchInstanceMethods, this function searches - * either instance or class methods. - * Depending on searchSuperClassesm this function searches - * either the specified class only or also its superclasses.
- * To obtain the implementation pointer IMP use returnValue->method_imp - * which should be safe across all runtimes.
- * It should be safe to use this function in +load implementations.
- * This function should currently (June 2004) be considered WIP. - * Please follow potential changes (Name, parameters, ...) closely until - * it stabilizes. - */ -GS_EXPORT GSMethod -GSGetMethod(Class cls, SEL sel, - BOOL searchInstanceMethods, - BOOL searchSuperClasses); - -/** - * Deprecated .. does nothing. - */ -GS_EXPORT void -GSFlushMethodCacheForClass (Class cls); - -/** - * Deprecated .. use class_getInstanceVariable() - */ -GS_EXPORT GSIVar -GSCGetInstanceVariableDefinition(Class cls, const char *name); - -/** - * Deprecated .. use class_getInstanceVariable() - */ -GS_EXPORT GSIVar -GSObjCGetInstanceVariableDefinition(Class cls, NSString *name); - -/** - * GSObjCVersion() is deprecated ... use class_getVersion() - */ -GS_EXPORT int GSObjCVersion(Class cls); - -/** - * Quickly return autoreleased data storage area. - */ -GS_EXPORT void * -GSAutoreleasedBuffer(unsigned size); - -/** - *

Prints a message to fptr using the format string provided and any - * additional arguments. The format string is interpreted as by - * the NSString formatted initialisers, and understands the '%@' syntax - * for printing an object. - *

- *

The data is written to the file pointer in the default CString - * encoding if possible, as a UTF8 string otherwise. - *

- *

This function is recommended for printing general log messages. - * For debug messages use NSDebugLog() and friends. For error logging - * use NSLog(), and for warnings you might consider NSWarnLog(). - *

- */ -GS_EXPORT BOOL -GSPrintf (FILE *fptr, NSString *format, ...); - - - -GS_EXPORT NSArray * -GSObjCAllSubclassesOfClass(Class cls); - -GS_EXPORT NSArray * -GSObjCDirectSubclassesOfClass(Class cls); - -/** Function to change the class of the specified instance to newClass. - * This handles memory debugging issues in GNUstep-base and also - * deals with class finalisation issues in a garbage collecting - * environment, so you should use this function rather than attempting - * to swizzle class pointers directly. - */ -GS_EXPORT void -GSClassSwizzle(id instance, Class newClass); - -GS_EXPORT const char * -GSLastErrorStr(long error_id); - - - -#ifndef GS_MAX_OBJECTS_FROM_STACK -/** - * The number of objects to try to get from varargs into an array on - * the stack ... if there are more than this, use the heap. - * NB. This MUST be a multiple of 2 - */ -#define GS_MAX_OBJECTS_FROM_STACK 128 -#endif - -/** - *

This is a macro designed to minimise the use of memory allocation and - * deallocation when you need to work with a vararg list of objects.
- * The objects are unpacked from the vararg list into two 'C' arrays and - * then a code fragment you specify is able to make use of them before - * that 'C' array is destroyed. - *

- *

The firstObject argument is the name of the formal parameter in your - * method or function which precedes the ', ...' denoting variable args. - *

- *

The code argument is a piece of objective-c code to be executed to - * make use of the objects stored in the 'C' arrays.
- * When this code is called the unsigned integer '__count' will contain the - * number of objects unpacked, the pointer '__objects' will point to - * the first object in each pair, and the pointer '__pairs' will point - * to an array containing the second halves of the pairs of objects - * whose first halves are in '__objects'.
- * This lets you pack a list of the form 'key, value, key, value, ...' - * into an array of keys and an array of values. - *

- */ -#define GS_USEIDPAIRLIST(firstObject, code...) ({\ - va_list __ap; \ - unsigned int __max = GS_MAX_OBJECTS_FROM_STACK; \ - unsigned int __count = 0; \ - id __buf[__max]; \ - id *__objects = __buf; \ - id *__pairs = &__objects[__max/2]; \ - id __obj = firstObject; \ - va_start(__ap, firstObject); \ - while (__obj != nil && __count < __max) \ - { \ - if ((__count % 2) == 0) \ - { \ - __objects[__count/2] = __obj; \ - } \ - else \ - { \ - __pairs[__count/2] = __obj; \ - } \ - __obj = va_arg(__ap, id); \ - if (++__count == __max) \ - { \ - while (__obj != nil) \ - { \ - __count++; \ - __obj = va_arg(__ap, id); \ - } \ - } \ - } \ - if ((__count % 2) == 1) \ - { \ - __pairs[__count/2] = nil; \ - __count++; \ - } \ - va_end(__ap); \ - if (__count > __max) \ - { \ - unsigned int __tmp; \ - __objects = (id*)malloc(__count*sizeof(id)); \ - __pairs = &__objects[__count/2]; \ - __objects[0] = firstObject; \ - va_start(__ap, firstObject); \ - for (__tmp = 1; __tmp < __count; __tmp++) \ - { \ - if ((__tmp % 2) == 0) \ - { \ - __objects[__tmp/2] = va_arg(__ap, id); \ - } \ - else \ - { \ - __pairs[__tmp/2] = va_arg(__ap, id); \ - } \ - } \ - va_end(__ap); \ - } \ - code; \ - if (__objects != __buf) free(__objects); \ -}) - -/** - *

This is a macro designed to minimise the use of memory allocation and - * deallocation when you need to work with a vararg list of objects.
- * The objects are unpacked from the vararg list into a 'C' array and - * then a code fragment you specify is able to make use of them before - * that 'C' array is destroyed. - *

- *

The firstObject argument is the name of the formal parameter in your - * method or function which precedes the ', ...' denoting variable args. - *

- *

The code argument is a piece of objective-c code to be executed to - * make use of the objects stored in the 'C' array.
- * When this code is called the unsigned integer '__count' will contain the - * number of objects unpacked, and the pointer '__objects' will point to - * the unpacked objects, ie. firstObject followed by the vararg arguments - * up to (but not including) the first nil. - *

- */ -#define GS_USEIDLIST(firstObject, code...) ({\ - va_list __ap; \ - unsigned int __max = GS_MAX_OBJECTS_FROM_STACK; \ - unsigned int __count = 0; \ - id __buf[__max]; \ - id *__objects = __buf; \ - id __obj = firstObject; \ - va_start(__ap, firstObject); \ - while (__obj != nil && __count < __max) \ - { \ - __objects[__count] = __obj; \ - __obj = va_arg(__ap, id); \ - if (++__count == __max) \ - { \ - while (__obj != nil) \ - { \ - __count++; \ - __obj = va_arg(__ap, id); \ - } \ - } \ - } \ - va_end(__ap); \ - if (__count > __max) \ - { \ - unsigned int __tmp; \ - __objects = (id*)NSZoneMalloc(NSDefaultMallocZone(),__count*sizeof(id)); \ - va_start(__ap, firstObject); \ - __objects[0] = firstObject; \ - for (__tmp = 1; __tmp < __count; __tmp++) \ - { \ - __objects[__tmp] = va_arg(__ap, id); \ - } \ - va_end(__ap); \ - } \ - code; \ - if (__objects != __buf) NSZoneFree (NSDefaultMallocZone(),__objects); \ -}) - - -#ifdef __cplusplus -} -#endif - -#endif /* __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */ diff --git a/GSObjCRuntime.h b/GSObjCRuntime.h new file mode 120000 index 0000000..a74dcd5 --- /dev/null +++ b/GSObjCRuntime.h @@ -0,0 +1 @@ +include/CoreFoundation/./GSObjCRuntime.h \ No newline at end of file diff --git a/NSBasicHash.h b/NSBasicHash.h deleted file mode 100644 index bfc819a..0000000 --- a/NSBasicHash.h +++ /dev/null @@ -1,96 +0,0 @@ -#import - -#define NUM_BUCKET_SIZES 64 - -static const NSUInteger __NSBasicHashIPrimes[NUM_BUCKET_SIZES] = { - 0, 3, 7, 13, 23, 41, 71, 127, 191, 251, 383, 631, 1087, 1723, - 2803, 4523, 7351, 11959, 19447, 31231, 50683, 81919, 132607, - 214519, 346607, 561109, 907759, 1468927, 2376191, 3845119, - 6221311, 10066421, 16287743, 26354171, 42641881, 68996069, - 111638519, 180634607, 292272623, 472907251, -#if __LP64__ - 765180413UL, 1238087663UL, 2003267557UL, 3241355263UL, 5244622819UL, -#if 0 - 8485977589UL, 13730600407UL, 22216578047UL, 35947178479UL, - 58163756537UL, 94110934997UL, 152274691561UL, 246385626107UL, - 398660317687UL, 645045943807UL, 1043706260983UL, 1688752204787UL, - 2732458465769UL, 4421210670577UL, 7153669136377UL, - 11574879807461UL, 18728548943849UL, 30303428750843UL -#endif -#endif -}; - -static const NSUInteger __NSBasicHashCapacities[NUM_BUCKET_SIZES] = { - 0, 3, 6, 11, 19, 32, 52, 85, 118, 155, 237, 390, 672, 1065, - 1732, 2795, 4543, 7391, 12019, 19302, 31324, 50629, 81956, - 132580, 214215, 346784, 561026, 907847, 1468567, 2376414, - 3844982, 6221390, 10066379, 16287773, 26354132, 42641916, - 68996399, 111638327, 180634415, 292272755, -#if __LP64__ - 472907503UL, 765180257UL, 1238087439UL, 2003267722UL, 3241355160UL, -#if 0 - 5244622578UL, 8485977737UL, 13730600347UL, 22216578100UL, - 35947178453UL, 58163756541UL, 94110935011UL, 152274691274UL, - 246385626296UL, 398660317578UL, 645045943559UL, 1043706261135UL, - 1688752204693UL, 2732458465840UL, 4421210670552UL, - 7153669136706UL, 11574879807265UL, 18728548943682UL -#endif -#endif -}; - -static inline NSUInteger __NSBasicHashGetSizeIdx(NSUInteger size) { - for (NSUInteger idx = 0; idx < NUM_BUCKET_SIZES; idx++) { - if (__NSBasicHashCapacities[idx] > size) { - return idx; - } - } - - DEBUG_BREAK(); - return NSNotFound; -} - -static inline void *NSBasicHashAllocate(NSUInteger count, size_t size, NSUInteger *capacity, NSUInteger *sizeidx, BOOL throwOnMallocFailure) { - *sizeidx = __NSBasicHashGetSizeIdx(count); - *capacity = __NSBasicHashIPrimes[*sizeidx]; - void *buffer = calloc(*capacity, size); - if (buffer == NULL && throwOnMallocFailure) { - [NSException raise:NSMallocException format:@"Unable to allocate buffer"]; - } - return buffer; -} - -static inline void *NSBasicHashGrow(NSUInteger count, size_t size, void *buffer, NSUInteger *capacity, NSUInteger *sizeidx, BOOL throwOnMallocFailure) { - if (*capacity < count) { - *sizeidx = __NSBasicHashGetSizeIdx(count); - *capacity = __NSBasicHashIPrimes[*sizeidx]; - void *newBuffer = realloc(buffer, (*capacity) * size); - if (newBuffer == NULL && throwOnMallocFailure) { - free(buffer); - *capacity = 0; - [NSException raise:NSMallocException format:@"Unable to reallocate buffer"]; - } - buffer = newBuffer; - } - return buffer; -} - -static inline void *NSBasicHashTrim(NSUInteger count, size_t size, void *buffer, NSUInteger *capacity, BOOL throwOnMallocFailure) { - if (*capacity > count) { - void *newBuffer = realloc(buffer, count * size); - if (newBuffer == NULL && throwOnMallocFailure) { // very sad day indeed if trimming causes malloc failure... - free(buffer); - *capacity = 0; - [NSException raise:NSMallocException format:@"Unable to reallocate buffer"]; - } else { - *capacity = count * size; - } - buffer = newBuffer; - } - return buffer; -} - -static inline void NSBasicHashDeallocate(void *buffer) { - if (buffer) { - free(buffer); - } -} diff --git a/NSBasicHash.h b/NSBasicHash.h new file mode 120000 index 0000000..71d6958 --- /dev/null +++ b/NSBasicHash.h @@ -0,0 +1 @@ +include/CoreFoundation/./NSBasicHash.h \ No newline at end of file diff --git a/NSBlock.h b/NSBlock.h deleted file mode 100644 index 40ba9bb..0000000 --- a/NSBlock.h +++ /dev/null @@ -1,85 +0,0 @@ -#import -#import - -BLOCK_EXPORT void * _NSConcreteMallocBlock[32]; -BLOCK_EXPORT void * _NSConcreteAutoBlock[32]; -BLOCK_EXPORT void * _NSConcreteFinalizingBlock[32]; -BLOCK_EXPORT void * _NSConcreteWeakBlockVariable[32]; -BLOCK_EXPORT void * _NSConcreteGlobalBlock[32]; -BLOCK_EXPORT void * _NSConcreteStackBlock[32]; - -extern bool _Block_tryRetain(const void *aBlock); -extern bool _Block_isDeallocating(const void *aBlock); - -@interface NSBlock : NSObject - -- (void)performAfterDelay:(NSTimeInterval)delay; -- (void)invoke; -- (id)copyWithZone:(NSZone *)zone; -- (id)copy; - -@end - -@interface __NSStackBlock : NSBlock - -- (id)autorelease; -- (NSUInteger)retainCount; -- (oneway void)release; -- (id)retain; - -@end - -@interface __NSMallocBlock : NSBlock - -- (BOOL)_isDeallocating; -- (BOOL)_tryRetain; -- (unsigned int)retainCount; -- (oneway void)release; -- (id)retain; - -@end - -@interface __NSAutoBlock : NSBlock - -- (id)copyWithZone:(NSZone *)zone; -- (id)copy; - -@end - -@interface __NSFinalizingBlock : __NSAutoBlock - -- (void)finalize; - -@end - -@interface __NSGlobalBlock : NSBlock - -- (BOOL)_isDeallocating; -- (BOOL)_tryRetain; -- (NSUInteger)retainCount; -- (id)retain; -- (oneway void)release; -- (id)copyWithZone:(NSZone *)zone; -- (id)copy; - -@end - -struct Block_byref { - void *_field1; - struct Block_byref *_field2; - int _field3; - unsigned int _field4; - void *_field5; - void *_field6; -}; - -@interface __NSBlockVariable : NSObject { - struct Block_byref *forwarding; - int flags; - int size; - void *byref_keep; - void *byref_destroy; - id containedObject; -} - -@end diff --git a/NSBlock.h b/NSBlock.h new file mode 120000 index 0000000..a2312c3 --- /dev/null +++ b/NSBlock.h @@ -0,0 +1 @@ +include/CoreFoundation/./NSBlock.h \ No newline at end of file diff --git a/NSGenericDeallocHandler.h b/NSGenericDeallocHandler.h deleted file mode 100644 index 122e226..0000000 --- a/NSGenericDeallocHandler.h +++ /dev/null @@ -1,16 +0,0 @@ -#import - -void _NSSetDeallocHandler(id object, void (^block)(void)); - -__attribute__((visibility("hidden"), objc_root_class)) -@interface __NSGenericDeallocHandler { - Class isa; - void (^_block)(void); -} - -+ (void)initialize; -- (void)release; -- (NSUInteger)retainCount; -- (id)retain; - -@end diff --git a/NSGenericDeallocHandler.h b/NSGenericDeallocHandler.h new file mode 120000 index 0000000..a30365d --- /dev/null +++ b/NSGenericDeallocHandler.h @@ -0,0 +1 @@ +include/CoreFoundation/./NSGenericDeallocHandler.h \ No newline at end of file diff --git a/NSInvocationInternal.h b/NSInvocationInternal.h deleted file mode 100644 index 1b8d0e0..0000000 --- a/NSInvocationInternal.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -// By grabbing at least 4 words for retSize, we can blindly copy r0-r3 -// into retdata when returning from an invocation. -#define RET_SIZE_ARGS (4 * sizeof(int)) - -void __invoke__(void *send, void *retdata, marg_list args, size_t len, const char *rettype); - -extern void _CF_forwarding_prep_0(); -extern void _CF_forwarding_prep_1(); \ No newline at end of file diff --git a/NSInvocationInternal.h b/NSInvocationInternal.h new file mode 120000 index 0000000..975756f --- /dev/null +++ b/NSInvocationInternal.h @@ -0,0 +1 @@ +include/CoreFoundation/./NSInvocationInternal.h \ No newline at end of file diff --git a/NSMessageBuilder.h b/NSMessageBuilder.h deleted file mode 100644 index 10c6612..0000000 --- a/NSMessageBuilder.h +++ /dev/null @@ -1,19 +0,0 @@ -#import -#import - -extern id _NSMessageBuilder(id proxy, NSInvocation **inv, SEL _cmd, void *arg); - -NS_ROOT_CLASS -@interface __NSMessageBuilder -{ -@public - Class isa; - id _target; - id *_addr; -} - -+ (void)initialize; -- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel; -- (void)forwardInvocation:(NSInvocation *)inv; - -@end diff --git a/NSMessageBuilder.h b/NSMessageBuilder.h new file mode 120000 index 0000000..6029571 --- /dev/null +++ b/NSMessageBuilder.h @@ -0,0 +1 @@ +include/CoreFoundation/./NSMessageBuilder.h \ No newline at end of file diff --git a/NSNumberInternal.h b/NSNumberInternal.h deleted file mode 100644 index 3c47786..0000000 --- a/NSNumberInternal.h +++ /dev/null @@ -1,91 +0,0 @@ -#import "NSObjectInternal.h" -#import "CFInternal.h" -#import - -CF_EXPORT Boolean _CFNumberGetValue(CFNumberRef number, CFNumberType type, void *valuePtr); -CF_EXPORT CFNumberType _CFNumberGetType(CFNumberRef num); -CF_EXPORT CFNumberType _CFNumberGetType2(CFNumberRef number); -CF_EXPORT CFStringRef __CFNumberCreateFormattingDescription(CFAllocatorRef allocator, CFTypeRef cf, CFDictionaryRef formatOptions); - -__attribute__((visibility("hidden"))) -@interface __NSCFNumber : __NSCFType - -+ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key; -- (NSComparisonResult)compare:(id)other; -- (NSComparisonResult)_reverseCompare:(id)other; -- (Boolean)_getValue:(void *)value forType:(CFNumberType)type; -- (CFNumberType)_cfNumberType; -- (CFTypeID)_cfTypeID; -- (BOOL)boolValue; -- (unsigned int)unsignedIntegerValue; -- (int)integerValue; -- (double)doubleValue; -- (float)floatValue; -- (unsigned long long)unsignedLongLongValue; -- (long long)longLongValue; -- (unsigned long)unsignedLongValue; -- (long)longValue; -- (unsigned int)unsignedIntValue; -- (int)intValue; -- (unsigned short)unsignedShortValue; -- (short)shortValue; -- (unsigned char)unsignedCharValue; -- (BOOL)charValue; -- (const char *)objCType; -- (void)getValue:(void *)value; -- (id)copyWithZone:(NSZone *)zone; -- (id)stringValue; -- (id)description; -- (id)descriptionWithLocale:(id)locale; -- (unsigned int)retainCount; -- (BOOL)_isDeallocating; -- (BOOL)_tryRetain; -- (oneway void)release; -- (id)retain; -- (NSUInteger)hash; -- (BOOL)isEqual:(id)other; -- (BOOL)isEqualToNumber:(id)other; -- (BOOL)isNSNumber__; - -@end - -__attribute__((visibility("hidden"))) -@interface __NSCFBoolean : __NSCFType - -+ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key; -- (NSComparisonResult)compare:(id)other; -- (NSComparisonResult)_reverseCompare:(id)other; -- (BOOL)_getValue:(void *)val forType:(CFNumberType)type; -- (CFNumberType)_cfNumberType; -- (id)copyWithZone:(NSZone *)zone; -- (const char *)objCType; -- (void)getValue:(void *)value; -- (CFTypeID)_cfTypeID; -- (BOOL)boolValue; -- (unsigned int)unsignedIntegerValue; -- (int)integerValue; -- (double)doubleValue; -- (float)floatValue; -- (unsigned long long)unsignedLongLongValue; -- (long long)longLongValue; -- (unsigned long)unsignedLongValue; -- (long)longValue; -- (unsigned int)unsignedIntValue; -- (int)intValue; -- (unsigned short)unsignedShortValue; -- (short)shortValue; -- (unsigned char)unsignedCharValue; -- (BOOL)charValue; -- (id)stringValue; -- (id)description; -- (id)descriptionWithLocale:(id)locale; -- (unsigned int)retainCount; -- (BOOL)_isDeallocating; -- (BOOL)_tryRetain; -- (oneway void)release; -- (id)retain; -- (unsigned int)hash; -- (BOOL)isEqual:(id)other; -- (BOOL)isEqualToNumber:(id)otherNumber; - -@end diff --git a/NSNumberInternal.h b/NSNumberInternal.h new file mode 120000 index 0000000..48983bf --- /dev/null +++ b/NSNumberInternal.h @@ -0,0 +1 @@ +include/CoreFoundation/./NSNumberInternal.h \ No newline at end of file diff --git a/NSObjCRuntimeInternal.h b/NSObjCRuntimeInternal.h deleted file mode 100644 index 404886f..0000000 --- a/NSObjCRuntimeInternal.h +++ /dev/null @@ -1,24 +0,0 @@ -#include - -static inline const char *stripQualifiersAndComments(const char *decl) -{ - static const char *qualifiersAndComments = "nNoOrRV\""; - - // Skip type qualifiers. - while (*decl != 0 && strchr(qualifiersAndComments, *decl)) { - if (*decl == '"') { - decl++; - while (*decl++ != '"'); - } - else { - decl++; - } - } - - return decl; -} - - -const char *__NSGetSizeAndAlignment(const char *decl, NSUInteger *size, NSUInteger *alignment, BOOL stripSizeHints); - -#define _C_LNG_DBL 'D' //add missing long double method signature constant character diff --git a/NSObjCRuntimeInternal.h b/NSObjCRuntimeInternal.h new file mode 120000 index 0000000..b0ca4cf --- /dev/null +++ b/NSObjCRuntimeInternal.h @@ -0,0 +1 @@ +include/CoreFoundation/./NSObjCRuntimeInternal.h \ No newline at end of file diff --git a/NSSharedKeyDictionary.h b/NSSharedKeyDictionary.h deleted file mode 100644 index 9175e5a..0000000 --- a/NSSharedKeyDictionary.h +++ /dev/null @@ -1,30 +0,0 @@ -#import -#import "NSSharedKeySet.h" - -@interface NSSharedKeyDictionary : NSMutableDictionary { - NSSharedKeySet *_keyMap; - NSUInteger _count; - id *_values; - NSUInteger (*_ifkIMP)(id,SEL,id); - NSMutableDictionary *_sideDic; - NSUInteger _mutations; -} - -+ (id)sharedKeyDictionaryWithKeySet:(NSSharedKeySet *)keySet; -- (id)initWithKeySet:(NSSharedKeySet *)keySet; -- (id)initWithCoder:(NSCoder *)coder; -- (void)encodeWithCoder:(NSCoder *)coder; -- (Class)classForCoder; -- (id)mutableCopyWithZone:(NSZone *)zone; -- (id)copyWithZone:(NSZone *)zone; -- (void)dealloc; -- (NSSharedKeySet *)keySet; -- (void)removeObjectForKey:(id)key; -- (void)setObject:(id)object forKey:(id)key; -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained [])buffer count:(NSUInteger)len; -- (NSEnumerator *)keyEnumerator; -- (void)getObjects:(id *)objects andKeys:(id *)keys count:(NSUInteger)count; -- (id)objectForKey:(id)key; -- (NSUInteger)count; - -@end diff --git a/NSSharedKeyDictionary.h b/NSSharedKeyDictionary.h new file mode 120000 index 0000000..d7fc522 --- /dev/null +++ b/NSSharedKeyDictionary.h @@ -0,0 +1 @@ +include/CoreFoundation/./NSSharedKeyDictionary.h \ No newline at end of file diff --git a/NSSharedKeySet.h b/NSSharedKeySet.h deleted file mode 100644 index b5688a1..0000000 --- a/NSSharedKeySet.h +++ /dev/null @@ -1,29 +0,0 @@ -#import - -@class NSString; - -@interface NSSharedKeySet : NSObject -{ - NSUInteger _numKey; - id *_keys; - NSSharedKeySet *_subSharedKeySet; -} - -+ (id)keySetWithKeys:(NSArray *)keys; -- (NSUInteger)keySetCount; -- (void)dealloc; -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained [])buffer count:(NSUInteger)len; -- (id)keyAtIndex:(NSUInteger)index; -- (NSUInteger)indexForKey:(id)key; -- (NSArray *)allKeys; -- (NSUInteger)maximumIndex; -- (BOOL)isEmpty; -- (NSUInteger)count; -- (id)initWithCoder:(NSCoder *)coder; -- (void)encodeWithCoder:(NSCoder *)coder; -- (id)copyWithZone:(NSZone *)zone; -- (id)init; -- (id)initWithKeys:(id *)keys count:(NSUInteger)count; -- (void)createSubclassCode:(NSString *)subclassName interface:(CFStringRef *)interface implementation:(CFStringRef *)implementation; - -@end diff --git a/NSSharedKeySet.h b/NSSharedKeySet.h new file mode 120000 index 0000000..64e354c --- /dev/null +++ b/NSSharedKeySet.h @@ -0,0 +1 @@ +include/CoreFoundation/./NSSharedKeySet.h \ No newline at end of file diff --git a/NSZombie.h b/NSZombie.h deleted file mode 100644 index f9acaaf..0000000 --- a/NSZombie.h +++ /dev/null @@ -1,14 +0,0 @@ -#import -#import - -#define ZOMBIE_PREFIX "_NSZombie_" - -extern uint8_t __CFZombieEnabled; -extern uint8_t __CFDeallocateZombies; - -NS_ROOT_CLASS -@interface _NSZombie_ { - Class isa; -} - -@end diff --git a/NSZombie.h b/NSZombie.h new file mode 120000 index 0000000..981b5fe --- /dev/null +++ b/NSZombie.h @@ -0,0 +1 @@ +include/CoreFoundation/./NSZombie.h \ No newline at end of file diff --git a/TargetConditionals.h b/TargetConditionals.h deleted file mode 100644 index e9f4c6e..0000000 --- a/TargetConditionals.h +++ /dev/null @@ -1,17 +0,0 @@ -/* TargetConditionals.h - Copyright (c) 2010-2014, Apple Inc. All rights reserved. - For CF on Linux ONLY -*/ - -#ifndef __TARGETCONDITIONALS__ -#define __TARGETCONDITIONALS__ - -#define TARGET_OS_MAC 0 -#define TARGET_OS_WIN32 0 -#define TARGET_OS_UNIX 0 -#define TARGET_OS_EMBEDDED 0 -#define TARGET_OS_IPHONE 0 -#define TARGET_IPHONE_SIMULATOR 0 -#define TARGET_OS_LINUX 1 - -#endif /* __TARGETCONDITIONALS__ */ diff --git a/TargetConditionals.h b/TargetConditionals.h new file mode 120000 index 0000000..2c3b362 --- /dev/null +++ b/TargetConditionals.h @@ -0,0 +1 @@ +include/CoreFoundation/./TargetConditionals.h \ No newline at end of file diff --git a/_CFUtilities.h b/_CFUtilities.h deleted file mode 100644 index a78ae87..0000000 --- a/_CFUtilities.h +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -static char *CFStringUTF8Copy(CFStringRef cfString) { - CFIndex length = CFStringGetLength(cfString); - CFIndex size = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8); - char *buffer = (char *)malloc(size); - CFStringGetCString(cfString, buffer, size, kCFStringEncodingUTF8); - return buffer; -} diff --git a/_CFUtilities.h b/_CFUtilities.h new file mode 120000 index 0000000..c989205 --- /dev/null +++ b/_CFUtilities.h @@ -0,0 +1 @@ +include/CoreFoundation/./_CFUtilities.h \ No newline at end of file diff --git a/include/CoreFoundation/CFArray.h b/include/CoreFoundation/CFArray.h new file mode 100644 index 0000000..96d98fe --- /dev/null +++ b/include/CoreFoundation/CFArray.h @@ -0,0 +1,696 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFArray.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +/*! + @header CFArray + CFArray implements an ordered, compact container of pointer-sized + values. Values are accessed via integer keys (indices), from the + range 0 to N-1, where N is the number of values in the array when + an operation is performed. The array is said to be "compact" because + deleted or inserted values do not leave a gap in the key space -- + the values with higher-numbered indices have their indices + renumbered lower (or higher, in the case of insertion) so that the + set of valid indices is always in the integer range [0, N-1]. Thus, + the index to access a particular value in the array may change over + time as other values are inserted into or deleted from the array. + + Arrays come in two flavors, immutable, which cannot have values + added to them or removed from them after the array is created, and + mutable, to which you can add values or from which remove values. + Mutable arrays can have an unlimited number of values (or rather, + limited only by constraints external to CFArray, like the amount + of available memory). + + As with all CoreFoundation collection types, arrays maintain hard + references on the values you put in them, but the retaining and + releasing functions are user-defined callbacks that can actually do + whatever the user wants (for example, nothing). + + Computational Complexity + The access time for a value in the array is guaranteed to be at + worst O(lg N) for any implementation, current and future, but will + often be O(1) (constant time). Linear search operations similarly + have a worst case complexity of O(N*lg N), though typically the + bounds will be tighter, and so on. Insertion or deletion operations + will typically be linear in the number of values in the array, but + may be O(N*lg N) clearly in the worst case in some implementations. + There are no favored positions within the array for performance; + that is, it is not necessarily faster to access values with low + indices, or to insert or delete values with high indices, or + whatever. +*/ + +#if !defined(__COREFOUNDATION_CFARRAY__) +#define __COREFOUNDATION_CFARRAY__ 1 + +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +/*! + @typedef CFArrayCallBacks + Structure containing the callbacks of a CFArray. + @field version The version number of the structure type being passed + in as a parameter to the CFArray creation functions. This + structure is version 0. + @field retain The callback used to add a retain for the array on + values as they are put into the array. This callback returns + the value to store in the array, which is usually the value + parameter passed to this callback, but may be a different + value if a different value should be stored in the array. + The array's allocator is passed as the first argument. + @field release The callback used to remove a retain previously added + for the array from values as they are removed from the + array. The array's allocator is passed as the first + argument. + @field copyDescription The callback used to create a descriptive + string representation of each value in the array. This is + used by the CFCopyDescription() function. + @field equal The callback used to compare values in the array for + equality for some operations. +*/ +typedef const void * (*CFArrayRetainCallBack)(CFAllocatorRef allocator, const void *value); +typedef void (*CFArrayReleaseCallBack)(CFAllocatorRef allocator, const void *value); +typedef CFStringRef (*CFArrayCopyDescriptionCallBack)(const void *value); +typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2); +typedef struct { + CFIndex version; + CFArrayRetainCallBack retain; + CFArrayReleaseCallBack release; + CFArrayCopyDescriptionCallBack copyDescription; + CFArrayEqualCallBack equal; +} CFArrayCallBacks; + +/*! + @constant kCFTypeArrayCallBacks + Predefined CFArrayCallBacks structure containing a set of callbacks + appropriate for use when the values in a CFArray are all CFTypes. +*/ +CF_EXPORT +const CFArrayCallBacks kCFTypeArrayCallBacks; + +/*! + @typedef CFArrayApplierFunction + Type of the callback function used by the apply functions of + CFArrays. + @param value The current value from the array. + @param context The user-defined context parameter given to the apply + function. +*/ +typedef void (*CFArrayApplierFunction)(const void *value, void *context); + +/*! + @typedef CFArrayRef + This is the type of a reference to immutable CFArrays. +*/ +typedef const struct CF_BRIDGED_TYPE(NSArray) __CFArray * CFArrayRef; + +/*! + @typedef CFMutableArrayRef + This is the type of a reference to mutable CFArrays. +*/ +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableArray) __CFArray * CFMutableArrayRef; + +/*! + @function CFArrayGetTypeID + Returns the type identifier of all CFArray instances. +*/ +CF_EXPORT +CFTypeID CFArrayGetTypeID(void); + +/*! + @function CFArrayCreate + Creates a new immutable array with the given values. + @param allocator The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param values A C array of the pointer-sized values to be in the + array. The values in the array are ordered in the same order + in which they appear in this C array. This parameter may be + NULL if the numValues parameter is 0. This C array is not + changed or freed by this function. If this parameter is not + a valid pointer to a C array of at least numValues pointers, + the behavior is undefined. + @param numValues The number of values to copy from the values C + array into the CFArray. This number will be the count of the + array. + If this parameter is negative, or greater than the number of + values actually in the value's C array, the behavior is + undefined. + @param callBacks A pointer to a CFArrayCallBacks structure + initialized with the callbacks for the array to use on each + value in the array. The retain callback will be used within + this function, for example, to retain all of the new values + from the values C array. A copy of the contents of the + callbacks structure is made, so that a pointer to a + structure on the stack can be passed in, or can be reused + for multiple array creations. If the version field of this + callbacks structure is not one of the defined ones for + CFArray, the behavior is undefined. The retain field may be + NULL, in which case the CFArray will do nothing to add a + retain to the contained values for the array. The release + field may be NULL, in which case the CFArray will do nothing + to remove the array's retain (if any) on the values when the + array is destroyed. If the copyDescription field is NULL, + the array will create a simple description for the value. If + the equal field is NULL, the array will use pointer equality + to test for equality of values. This callbacks parameter + itself may be NULL, which is treated as if a valid structure + of version 0 with all fields NULL had been passed in. + Otherwise, if any of the fields are not valid pointers to + functions of the correct type, or this parameter is not a + valid pointer to a CFArrayCallBacks callbacks structure, + the behavior is undefined. If any of the values put into the + array is not one understood by one of the callback functions + the behavior when that callback function is used is + undefined. + @result A reference to the new immutable CFArray. +*/ +CF_EXPORT +CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks); + +/*! + @function CFArrayCreateCopy + Creates a new immutable array with the values from the given array. + @param allocator The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param theArray The array which is to be copied. The values from the + array are copied as pointers into the new array (that is, + the values themselves are copied, not that which the values + point to, if anything). However, the values are also + retained by the new array. The count of the new array will + be the same as the given array. The new array uses the same + callbacks as the array to be copied. If this parameter is + not a valid CFArray, the behavior is undefined. + @result A reference to the new immutable CFArray. +*/ +CF_EXPORT +CFArrayRef CFArrayCreateCopy(CFAllocatorRef allocator, CFArrayRef theArray); + +/*! + @function CFArrayCreateMutable + Creates a new empty mutable array. + @param allocator The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param capacity A hint about the number of values that will be held + by the CFArray. Pass 0 for no hint. The implementation may + ignore this hint, or may use it to optimize various + operations. An array's actual capacity is only limited by + address space and available memory constraints). If this + parameter is negative, the behavior is undefined. + @param callBacks A pointer to a CFArrayCallBacks structure + initialized with the callbacks for the array to use on each + value in the array. A copy of the contents of the + callbacks structure is made, so that a pointer to a + structure on the stack can be passed in, or can be reused + for multiple array creations. If the version field of this + callbacks structure is not one of the defined ones for + CFArray, the behavior is undefined. The retain field may be + NULL, in which case the CFArray will do nothing to add a + retain to the contained values for the array. The release + field may be NULL, in which case the CFArray will do nothing + to remove the array's retain (if any) on the values when the + array is destroyed. If the copyDescription field is NULL, + the array will create a simple description for the value. If + the equal field is NULL, the array will use pointer equality + to test for equality of values. This callbacks parameter + itself may be NULL, which is treated as if a valid structure + of version 0 with all fields NULL had been passed in. + Otherwise, if any of the fields are not valid pointers to + functions of the correct type, or this parameter is not a + valid pointer to a CFArrayCallBacks callbacks structure, + the behavior is undefined. If any of the values put into the + array is not one understood by one of the callback functions + the behavior when that callback function is used is + undefined. + @result A reference to the new mutable CFArray. +*/ +CF_EXPORT +CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks); + +/*! + @function CFArrayCreateMutableCopy + Creates a new mutable array with the values from the given array. + @param allocator The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param capacity A hint about the number of values that will be held + by the CFArray. Pass 0 for no hint. The implementation may + ignore this hint, or may use it to optimize various + operations. An array's actual capacity is only limited by + address space and available memory constraints). + This parameter must be greater than or equal + to the count of the array which is to be copied, or the + behavior is undefined. If this parameter is negative, the + behavior is undefined. + @param theArray The array which is to be copied. The values from the + array are copied as pointers into the new array (that is, + the values themselves are copied, not that which the values + point to, if anything). However, the values are also + retained by the new array. The count of the new array will + be the same as the given array. The new array uses the same + callbacks as the array to be copied. If this parameter is + not a valid CFArray, the behavior is undefined. + @result A reference to the new mutable CFArray. +*/ +CF_EXPORT +CFMutableArrayRef CFArrayCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFArrayRef theArray); + +/*! + @function CFArrayGetCount + Returns the number of values currently in the array. + @param theArray The array to be queried. If this parameter is not a valid + CFArray, the behavior is undefined. + @result The number of values in the array. +*/ +CF_EXPORT +CFIndex CFArrayGetCount(CFArrayRef theArray); + +/*! + @function CFArrayGetCountOfValue + Counts the number of times the given value occurs in the array. + @param theArray The array to be searched. If this parameter is not a + valid CFArray, the behavior is undefined. + @param range The range within the array to search. If the range + location or end point (defined by the location plus length + minus 1) is outside the index space of the array (0 to + N-1 inclusive, where N is the count of the array), the + behavior is undefined. If the range length is negative, the + behavior is undefined. The range may be empty (length 0). + @param value The value for which to find matches in the array. The + equal() callback provided when the array was created is + used to compare. If the equal() callback was NULL, pointer + equality (in C, ==) is used. If value, or any of the values + in the array, are not understood by the equal() callback, + the behavior is undefined. + @result The number of times the given value occurs in the array, + within the specified range. +*/ +CF_EXPORT +CFIndex CFArrayGetCountOfValue(CFArrayRef theArray, CFRange range, const void *value); + +/*! + @function CFArrayContainsValue + Reports whether or not the value is in the array. + @param theArray The array to be searched. If this parameter is not a + valid CFArray, the behavior is undefined. + @param range The range within the array to search. If the range + location or end point (defined by the location plus length + minus 1) is outside the index space of the array (0 to + N-1 inclusive, where N is the count of the array), the + behavior is undefined. If the range length is negative, the + behavior is undefined. The range may be empty (length 0). + @param value The value for which to find matches in the array. The + equal() callback provided when the array was created is + used to compare. If the equal() callback was NULL, pointer + equality (in C, ==) is used. If value, or any of the values + in the array, are not understood by the equal() callback, + the behavior is undefined. + @result true, if the value is in the specified range of the array, + otherwise false. +*/ +CF_EXPORT +Boolean CFArrayContainsValue(CFArrayRef theArray, CFRange range, const void *value); + +/*! + @function CFArrayGetValueAtIndex + Retrieves the value at the given index. + @param theArray The array to be queried. If this parameter is not a + valid CFArray, the behavior is undefined. + @param idx The index of the value to retrieve. If the index is + outside the index space of the array (0 to N-1 inclusive, + where N is the count of the array), the behavior is + undefined. + @result The value with the given index in the array. +*/ +CF_EXPORT +const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx); + +/*! + @function CFArrayGetValues + Fills the buffer with values from the array. + @param theArray The array to be queried. If this parameter is not a + valid CFArray, the behavior is undefined. + @param range The range of values within the array to retrieve. If + the range location or end point (defined by the location + plus length minus 1) is outside the index space of the + array (0 to N-1 inclusive, where N is the count of the + array), the behavior is undefined. If the range length is + negative, the behavior is undefined. The range may be empty + (length 0), in which case no values are put into the buffer. + @param values A C array of pointer-sized values to be filled with + values from the array. The values in the C array are ordered + in the same order in which they appear in the array. If this + parameter is not a valid pointer to a C array of at least + range.length pointers, the behavior is undefined. +*/ +CF_EXPORT +void CFArrayGetValues(CFArrayRef theArray, CFRange range, const void **values); + +/*! + @function CFArrayApplyFunction + Calls a function once for each value in the array. + @param theArray The array to be operated upon. If this parameter is not + a valid CFArray, the behavior is undefined. + @param range The range of values within the array to which to apply + the function. If the range location or end point (defined by + the location plus length minus 1) is outside the index + space of the array (0 to N-1 inclusive, where N is the count + of the array), the behavior is undefined. If the range + length is negative, the behavior is undefined. The range may + be empty (length 0). + @param applier The callback function to call once for each value in + the given range in the array. If this parameter is not a + pointer to a function of the correct prototype, the behavior + is undefined. If there are values in the range which the + applier function does not expect or cannot properly apply + to, the behavior is undefined. + @param context A pointer-sized user-defined value, which is passed + as the second parameter to the applier function, but is + otherwise unused by this function. If the context is not + what is expected by the applier function, the behavior is + undefined. +*/ +CF_EXPORT +void CFArrayApplyFunction(CFArrayRef theArray, CFRange range, CFArrayApplierFunction applier, void *context); + +/*! + @function CFArrayGetFirstIndexOfValue + Searches the array for the value. + @param theArray The array to be searched. If this parameter is not a + valid CFArray, the behavior is undefined. + @param range The range within the array to search. If the range + location or end point (defined by the location plus length + minus 1) is outside the index space of the array (0 to + N-1 inclusive, where N is the count of the array), the + behavior is undefined. If the range length is negative, the + behavior is undefined. The range may be empty (length 0). + The search progresses from the smallest index defined by + the range to the largest. + @param value The value for which to find a match in the array. The + equal() callback provided when the array was created is + used to compare. If the equal() callback was NULL, pointer + equality (in C, ==) is used. If value, or any of the values + in the array, are not understood by the equal() callback, + the behavior is undefined. + @result The lowest index of the matching values in the range, or + kCFNotFound if no value in the range matched. +*/ +CF_EXPORT +CFIndex CFArrayGetFirstIndexOfValue(CFArrayRef theArray, CFRange range, const void *value); + +/*! + @function CFArrayGetLastIndexOfValue + Searches the array for the value. + @param theArray The array to be searched. If this parameter is not a + valid CFArray, the behavior is undefined. + @param range The range within the array to search. If the range + location or end point (defined by the location plus length + minus 1) is outside the index space of the array (0 to + N-1 inclusive, where N is the count of the array), the + behavior is undefined. If the range length is negative, the + behavior is undefined. The range may be empty (length 0). + The search progresses from the largest index defined by the + range to the smallest. + @param value The value for which to find a match in the array. The + equal() callback provided when the array was created is + used to compare. If the equal() callback was NULL, pointer + equality (in C, ==) is used. If value, or any of the values + in the array, are not understood by the equal() callback, + the behavior is undefined. + @result The highest index of the matching values in the range, or + kCFNotFound if no value in the range matched. +*/ +CF_EXPORT +CFIndex CFArrayGetLastIndexOfValue(CFArrayRef theArray, CFRange range, const void *value); + +/*! + @function CFArrayBSearchValues + Searches the array for the value using a binary search algorithm. + @param theArray The array to be searched. If this parameter is not a + valid CFArray, the behavior is undefined. If the array is + not sorted from least to greatest according to the + comparator function, the behavior is undefined. + @param range The range within the array to search. If the range + location or end point (defined by the location plus length + minus 1) is outside the index space of the array (0 to + N-1 inclusive, where N is the count of the array), the + behavior is undefined. If the range length is negative, the + behavior is undefined. The range may be empty (length 0). + @param value The value for which to find a match in the array. If + value, or any of the values in the array, are not understood + by the comparator callback, the behavior is undefined. + @param comparator The function with the comparator function type + signature which is used in the binary search operation to + compare values in the array with the given value. If this + parameter is not a pointer to a function of the correct + prototype, the behavior is undefined. If there are values + in the range which the comparator function does not expect + or cannot properly compare, the behavior is undefined. + @param context A pointer-sized user-defined value, which is passed + as the third parameter to the comparator function, but is + otherwise unused by this function. If the context is not + what is expected by the comparator function, the behavior is + undefined. + @result The return value is either 1) the index of a value that + matched, if the target value matches one or more in the + range, 2) greater than or equal to the end point of the + range, if the value is greater than all the values in the + range, or 3) the index of the value greater than the target + value, if the value lies between two of (or less than all + of) the values in the range. +*/ +CF_EXPORT +CFIndex CFArrayBSearchValues(CFArrayRef theArray, CFRange range, const void *value, CFComparatorFunction comparator, void *context); + +/*! + @function CFArrayAppendValue + Adds the value to the array giving it a new largest index. + @param theArray The array to which the value is to be added. If this + parameter is not a valid mutable CFArray, the behavior is + undefined. + @param value The value to add to the array. The value is retained by + the array using the retain callback provided when the array + was created. If the value is not of the sort expected by the + retain callback, the behavior is undefined. The value is + assigned to the index one larger than the previous largest + index, and the count of the array is increased by one. +*/ +CF_EXPORT +void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value); + +/*! + @function CFArrayInsertValueAtIndex + Adds the value to the array, giving it the given index. + @param theArray The array to which the value is to be added. If this + parameter is not a valid mutable CFArray, the behavior is + undefined. + @param idx The index to which to add the new value. If the index is + outside the index space of the array (0 to N inclusive, + where N is the count of the array before the operation), the + behavior is undefined. If the index is the same as N, this + function has the same effect as CFArrayAppendValue(). + @param value The value to add to the array. The value is retained by + the array using the retain callback provided when the array + was created. If the value is not of the sort expected by the + retain callback, the behavior is undefined. The value is + assigned to the given index, and all values with equal and + larger indices have their indexes increased by one. +*/ +CF_EXPORT +void CFArrayInsertValueAtIndex(CFMutableArrayRef theArray, CFIndex idx, const void *value); + +/*! + @function CFArraySetValueAtIndex + Changes the value with the given index in the array. + @param theArray The array in which the value is to be changed. If this + parameter is not a valid mutable CFArray, the behavior is + undefined. + @param idx The index to which to set the new value. If the index is + outside the index space of the array (0 to N inclusive, + where N is the count of the array before the operation), the + behavior is undefined. If the index is the same as N, this + function has the same effect as CFArrayAppendValue(). + @param value The value to set in the array. The value is retained by + the array using the retain callback provided when the array + was created, and the previous value with that index is + released. If the value is not of the sort expected by the + retain callback, the behavior is undefined. The indices of + other values is not affected. +*/ +CF_EXPORT +void CFArraySetValueAtIndex(CFMutableArrayRef theArray, CFIndex idx, const void *value); + +/*! + @function CFArrayRemoveValueAtIndex + Removes the value with the given index from the array. + @param theArray The array from which the value is to be removed. If + this parameter is not a valid mutable CFArray, the behavior + is undefined. + @param idx The index from which to remove the value. If the index is + outside the index space of the array (0 to N-1 inclusive, + where N is the count of the array before the operation), the + behavior is undefined. +*/ +CF_EXPORT +void CFArrayRemoveValueAtIndex(CFMutableArrayRef theArray, CFIndex idx); + +/*! + @function CFArrayRemoveAllValues + Removes all the values from the array, making it empty. + @param theArray The array from which all of the values are to be + removed. If this parameter is not a valid mutable CFArray, + the behavior is undefined. +*/ +CF_EXPORT +void CFArrayRemoveAllValues(CFMutableArrayRef theArray); + +/*! + @function CFArrayReplaceValues + Replaces a range of values in the array. + @param theArray The array from which all of the values are to be + removed. If this parameter is not a valid mutable CFArray, + the behavior is undefined. + @param range The range of values within the array to replace. If the + range location or end point (defined by the location plus + length minus 1) is outside the index space of the array (0 + to N inclusive, where N is the count of the array), the + behavior is undefined. If the range length is negative, the + behavior is undefined. The range may be empty (length 0), + in which case the new values are merely inserted at the + range location. + @param newValues A C array of the pointer-sized values to be placed + into the array. The new values in the array are ordered in + the same order in which they appear in this C array. This + parameter may be NULL if the newCount parameter is 0. This + C array is not changed or freed by this function. If this + parameter is not a valid pointer to a C array of at least + newCount pointers, the behavior is undefined. + @param newCount The number of values to copy from the values C + array into the CFArray. If this parameter is different than + the range length, the excess newCount values will be + inserted after the range, or the excess range values will be + deleted. This parameter may be 0, in which case no new + values are replaced into the array and the values in the + range are simply removed. If this parameter is negative, or + greater than the number of values actually in the newValues + C array, the behavior is undefined. +*/ +CF_EXPORT +void CFArrayReplaceValues(CFMutableArrayRef theArray, CFRange range, const void **newValues, CFIndex newCount); + +/*! + @function CFArrayExchangeValuesAtIndices + Exchanges the values at two indices of the array. + @param theArray The array of which the values are to be swapped. If + this parameter is not a valid mutable CFArray, the behavior + is undefined. + @param idx1 The first index whose values should be swapped. If the + index is outside the index space of the array (0 to N-1 + inclusive, where N is the count of the array before the + operation), the behavior is undefined. + @param idx2 The second index whose values should be swapped. If the + index is outside the index space of the array (0 to N-1 + inclusive, where N is the count of the array before the + operation), the behavior is undefined. +*/ +CF_EXPORT +void CFArrayExchangeValuesAtIndices(CFMutableArrayRef theArray, CFIndex idx1, CFIndex idx2); + +/*! + @function CFArraySortValues + Sorts the values in the array using the given comparison function. + @param theArray The array whose values are to be sorted. If this + parameter is not a valid mutable CFArray, the behavior is + undefined. + @param range The range of values within the array to sort. If the + range location or end point (defined by the location plus + length minus 1) is outside the index space of the array (0 + to N-1 inclusive, where N is the count of the array), the + behavior is undefined. If the range length is negative, the + behavior is undefined. The range may be empty (length 0). + @param comparator The function with the comparator function type + signature which is used in the sort operation to compare + values in the array with the given value. If this parameter + is not a pointer to a function of the correct prototype, the + the behavior is undefined. If there are values in the array + which the comparator function does not expect or cannot + properly compare, the behavior is undefined. The values in + the range are sorted from least to greatest according to + this function. + @param context A pointer-sized user-defined value, which is passed + as the third parameter to the comparator function, but is + otherwise unused by this function. If the context is not + what is expected by the comparator function, the behavior is + undefined. +*/ +CF_EXPORT +void CFArraySortValues(CFMutableArrayRef theArray, CFRange range, CFComparatorFunction comparator, void *context); + +/*! + @function CFArrayAppendArray + Adds the values from an array to another array. + @param theArray The array to which values from the otherArray are to + be added. If this parameter is not a valid mutable CFArray, + the behavior is undefined. + @param otherArray The array providing the values to be added to the + array. If this parameter is not a valid CFArray, the + behavior is undefined. + @param otherRange The range within the otherArray from which to add + the values to the array. If the range location or end point + (defined by the location plus length minus 1) is outside + the index space of the otherArray (0 to N-1 inclusive, where + N is the count of the otherArray), the behavior is + undefined. The new values are retained by the array using + the retain callback provided when the array was created. If + the values are not of the sort expected by the retain + callback, the behavior is undefined. The values are assigned + to the indices one larger than the previous largest index + in the array, and beyond, and the count of the array is + increased by range.length. The values are assigned new + indices in the array from smallest to largest index in the + order in which they appear in the otherArray. +*/ +CF_EXPORT +void CFArrayAppendArray(CFMutableArrayRef theArray, CFArrayRef otherArray, CFRange otherRange); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFARRAY__ */ + diff --git a/include/CoreFoundation/CFAttributedString.h b/include/CoreFoundation/CFAttributedString.h new file mode 100644 index 0000000..259a4d4 --- /dev/null +++ b/include/CoreFoundation/CFAttributedString.h @@ -0,0 +1,40 @@ +#if !defined(__COREFOUNDATION_CFATTRIBUTEDSTRING__) +#define __COREFOUNDATION_CFATTRIBUTEDSTRING__ 1 + +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef const struct __CFAttributedString *CFAttributedStringRef; +typedef struct __CFAttributedString *CFMutableAttributedStringRef; + +CF_EXPORT CFTypeID CFAttributedStringGetTypeID(void); +CF_EXPORT CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes); +CF_EXPORT CFAttributedStringRef CFAttributedStringCreateWithSubstring(CFAllocatorRef alloc, CFAttributedStringRef aStr, CFRange range); +CF_EXPORT CFAttributedStringRef CFAttributedStringCreateCopy(CFAllocatorRef alloc, CFAttributedStringRef aStr); +CF_EXPORT CFStringRef CFAttributedStringGetString(CFAttributedStringRef aStr); +CF_EXPORT CFIndex CFAttributedStringGetLength(CFAttributedStringRef aStr); +CF_EXPORT CFDictionaryRef CFAttributedStringGetAttributes(CFAttributedStringRef aStr, CFIndex loc, CFRange *effectiveRange); +CF_EXPORT CFTypeRef CFAttributedStringGetAttribute(CFAttributedStringRef aStr, CFIndex loc, CFStringRef attrName, CFRange *effectiveRange); +CF_EXPORT CFDictionaryRef CFAttributedStringGetAttributesAndLongestEffectiveRange(CFAttributedStringRef aStr, CFIndex loc, CFRange inRange, CFRange *longestEffectiveRange); +CF_EXPORT CFTypeRef CFAttributedStringGetAttributeAndLongestEffectiveRange(CFAttributedStringRef aStr, CFIndex loc, CFStringRef attrName, CFRange inRange, CFRange *longestEffectiveRange); +CF_EXPORT CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr); +CF_EXPORT CFMutableAttributedStringRef CFAttributedStringCreateMutable(CFAllocatorRef alloc, CFIndex maxLength); +CF_EXPORT void CFAttributedStringReplaceString(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef replacement); +CF_EXPORT CFMutableStringRef CFAttributedStringGetMutableString(CFMutableAttributedStringRef aStr); +CF_EXPORT void CFAttributedStringSetAttributes(CFMutableAttributedStringRef aStr, CFRange range, CFDictionaryRef replacement, Boolean clearOtherAttributes); +CF_EXPORT void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value); +CF_EXPORT void CFAttributedStringRemoveAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName); +CF_EXPORT void CFAttributedStringReplaceAttributedString(CFMutableAttributedStringRef aStr, CFRange range, CFAttributedStringRef replacement); +CF_EXPORT void CFAttributedStringBeginEditing(CFMutableAttributedStringRef aStr); +CF_EXPORT void CFAttributedStringEndEditing(CFMutableAttributedStringRef aStr); + +CF_EXPORT void _CFAttributedStringSetMutable(CFAttributedStringRef aStr, Boolean isMutable); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif diff --git a/include/CoreFoundation/CFAvailability.h b/include/CoreFoundation/CFAvailability.h new file mode 100644 index 0000000..39bd235 --- /dev/null +++ b/include/CoreFoundation/CFAvailability.h @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFAvailability.h + Copyright (c) 2013-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFAVAILABILITY__) +#define __COREFOUNDATION_CFAVAILABILITY__ 1 + +#include +#include + +#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32) +// Even if unused, these must remain here for compatibility, because projects rely on them being included. +#include +#endif + +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#ifndef __has_extension +#define __has_extension(x) 0 +#endif + +// The arguments to these availability macros is a version number, e.g. 10_6, 3_0 or 'NA' +// To use a deprecation message with the macro, add a string as the last argument. +#if __has_feature(attribute_availability_with_message) + +#define __NSi_2_0 introduced=2.0 +#define __NSi_2_1 introduced=2.1 +#define __NSi_2_2 introduced=2.2 +#define __NSi_3_0 introduced=3.0 +#define __NSi_3_1 introduced=3.1 +#define __NSi_3_2 introduced=3.2 +#define __NSi_4_0 introduced=4.0 +#define __NSi_4_1 introduced=4.1 +#define __NSi_4_2 introduced=4.2 +#define __NSi_4_3 introduced=4.3 +#define __NSi_5_0 introduced=5.0 +#define __NSi_5_1 introduced=5.1 +#define __NSi_6_0 introduced=6.0 +#define __NSi_6_1 introduced=6.1 +#define __NSi_7_0 introduced=7.0 +#define __NSi_7_1 introduced=7.1 +#define __NSi_8_0 introduced=8.0 +#define __NSi_8_1 introduced=8.1 +#define __NSi_9_0 introduced=9.0 +#define __NSi_9_1 introduced=9.1 +#define __NSi_10_0 introduced=10.0 +#define __NSi_10_1 introduced=10.1 +#define __NSi_10_2 introduced=10.2 +#define __NSi_10_3 introduced=10.3 +#define __NSi_10_4 introduced=10.4 +#define __NSi_10_5 introduced=10.5 +#define __NSi_10_6 introduced=10.6 +#define __NSi_10_7 introduced=10.7 +#define __NSi_10_8 introduced=10.8 +#define __NSi_10_9 introduced=10.9 +#define __NSi_10_10 introduced=10.10 +#define __NSi_10_10_2 introduced=10.10.2 +#define __NSi_10_10_3 introduced=10.10.3 +#define __NSi_10_11 introduced=10.11 +#define __NSi_10_12 introduced=10.12 + +#define __NSd_2_0 ,deprecated=2.0 +#define __NSd_2_1 ,deprecated=2.1 +#define __NSd_2_2 ,deprecated=2.2 +#define __NSd_3_0 ,deprecated=3.0 +#define __NSd_3_1 ,deprecated=3.1 +#define __NSd_3_2 ,deprecated=3.2 +#define __NSd_4_0 ,deprecated=4.0 +#define __NSd_4_1 ,deprecated=4.1 +#define __NSd_4_2 ,deprecated=4.2 +#define __NSd_4_3 ,deprecated=4.3 +#define __NSd_5_0 ,deprecated=5.0 +#define __NSd_5_1 ,deprecated=5.1 +#define __NSd_6_0 ,deprecated=6.0 +#define __NSd_6_1 ,deprecated=6.1 +#define __NSd_7_0 ,deprecated=7.0 +#define __NSd_7_1 ,deprecated=7.1 +#define __NSd_8_0 ,deprecated=8.0 +#define __NSd_8_1 ,deprecated=8.1 +#define __NSd_9_0 ,deprecated=9.0 +#define __NSd_9_1 ,deprecated=9.1 +#define __NSd_10_0 ,deprecated=10.0 +#define __NSd_10_1 ,deprecated=10.1 +#define __NSd_10_2 ,deprecated=10.2 +#define __NSd_10_3 ,deprecated=10.3 +#define __NSd_10_4 ,deprecated=10.4 +#define __NSd_10_5 ,deprecated=10.5 +#define __NSd_10_6 ,deprecated=10.6 +#define __NSd_10_7 ,deprecated=10.7 +#define __NSd_10_8 ,deprecated=10.8 +#define __NSd_10_9 ,deprecated=10.9 +#define __NSd_10_10 ,deprecated=10.10 +#define __NSd_10_10_2 ,deprecated=10.10.2 +#define __NSd_10_10_3 ,deprecated=10.10.3 +#define __NSd_10_11 ,deprecated=10.11 +#define __NSd_10_12 ,deprecated=10.12 + +#define __NSi_NA unavailable +#define __NSd_NA + +// Do not use TBD as an argument to NS_AVAILABLE +#define __NSi_TBD introduced=9876.5 + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) +// This section is for compilers targeting OS X which support attribute_availability_with_message + +#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(macosx,__NSi_##_mac))) +#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,__NSi_##_mac))) +#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable))) +#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __attribute__((availability(macosx,__NSi_##_macIntro __NSd_##_macDep,message="" __VA_ARGS__))) +#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __attribute__((availability(macosx,__NSi_##_macIntro __NSd_##_macDep,message="" __VA_ARGS__))) +#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __attribute__((availability(macosx,unavailable))) + +#elif (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +// This section is for compilers targeting iOS which support attribute_availability_with_message + +#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,__NSi_##_ios))) +#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(ios,unavailable))) +#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(ios,__NSi_##_ios))) +#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __attribute__((availability(ios,__NSi_##_iosIntro __NSd_##_iosDep,message="" __VA_ARGS__))) +#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __attribute__((availability(ios,unavailable))) +#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __attribute__((availability(ios,__NSi_##_iosIntro __NSd_##_iosDep,message="" __VA_ARGS__))) + +#endif + +#elif (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +// This section is for OS X or iOS, and compilers without support for attribute_availability_with_message. We fall back to Availability.h. + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 +#define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 __AVAILABILITY_INTERNAL_DEPRECATED +#endif + +#define CF_AVAILABLE(_mac, _ios) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_##_ios) +#define CF_AVAILABLE_MAC(_mac) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_NA) +#define CF_AVAILABLE_IOS(_ios) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_##_ios) +#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_##_macIntro, __MAC_##_macDep, __IPHONE_##_iosIntro, __IPHONE_##_iosDep) +#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_##_macIntro, __MAC_##_macDep, __IPHONE_NA, __IPHONE_NA) +#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_##_iosIntro, __IPHONE_##_iosDep) + +#endif // __has_feature(attribute_availability_with_message) + +#ifndef CF_AVAILABLE +// This section is for platforms which do not support availability +#define CF_AVAILABLE(_mac, _ios) +#define CF_AVAILABLE_MAC(_mac) +#define CF_AVAILABLE_IOS(_ios) +#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) +#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) +#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) +#endif + +// Older versions of these macros; use iOS versions instead +#define CF_AVAILABLE_IPHONE(_ios) CF_AVAILABLE_IOS(_ios) +#define CF_DEPRECATED_IPHONE(_iosIntro, _iosDep) CF_DEPRECATED_IOS(_iosIntro, _iosDep) + +// Enum availability macros +#if __has_feature(enumerator_attributes) && __has_attribute(availability) +#define CF_ENUM_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios) +#define CF_ENUM_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac) +#define CF_ENUM_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios) +#define CF_ENUM_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, __VA_ARGS__) +#define CF_ENUM_DEPRECATED_MAC(_macIntro, _macDep, ...) CF_DEPRECATED_MAC(_macIntro, _macDep, __VA_ARGS__) +#define CF_ENUM_DEPRECATED_IOS(_iosIntro, _iosDep, ...) CF_DEPRECATED_IOS(_iosIntro, _iosDep, __VA_ARGS__) +#else +#define CF_ENUM_AVAILABLE(_mac, _ios) +#define CF_ENUM_AVAILABLE_MAC(_mac) +#define CF_ENUM_AVAILABLE_IOS(_ios) +#define CF_ENUM_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) +#define CF_ENUM_DEPRECATED_MAC(_macIntro, _macDep, ...) +#define CF_ENUM_DEPRECATED_IOS(_iosIntro, _iosDep, ...) +#endif + +// Enums and Options +// Enums and Options +#define __CF_ENUM_GET_MACRO(_1, _2, NAME, ...) NAME +#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum)) +#define __CF_NAMED_ENUM(_type, _name) enum _name : _type _name; enum _name : _type +#define __CF_ANON_ENUM(_type) enum : _type +#if (__cplusplus) +#define CF_OPTIONS(_type, _name) _type _name; enum : _type +#else +#define CF_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type +#endif +#else +#define __CF_NAMED_ENUM(_type, _name) _type _name; enum +#define __CF_ANON_ENUM(_type) enum +#define CF_OPTIONS(_type, _name) _type _name; enum +#endif + +/* CF_ENUM supports the use of one or two arguments. The first argument is always the integer type used for the values of the enum. The second argument is an optional type name for the macro. When specifying a type name, you must precede the macro with 'typedef' like so: +typedef CF_ENUM(CFIndex, CFComparisonResult) { + ... +}; +If you do not specify a type name, do not use 'typdef', like so: +CF_ENUM(CFIndex) { + ... +}; +*/ +#define CF_ENUM(...) __CF_ENUM_GET_MACRO(__VA_ARGS__, __CF_NAMED_ENUM, __CF_ANON_ENUM, )(__VA_ARGS__) + +// Extension availability macros +#define CF_EXTENSION_UNAVAILABLE(_msg) __OS_EXTENSION_UNAVAILABLE(_msg) +#define CF_EXTENSION_UNAVAILABLE_MAC(_msg) __OSX_EXTENSION_UNAVAILABLE(_msg) +#define CF_EXTENSION_UNAVAILABLE_IOS(_msg) __IOS_EXTENSION_UNAVAILABLE(_msg) + +#endif // __COREFOUNDATION_CFAVAILABILITY__ diff --git a/include/CoreFoundation/CFBag.h b/include/CoreFoundation/CFBag.h new file mode 100644 index 0000000..41734e1 --- /dev/null +++ b/include/CoreFoundation/CFBag.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBag.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFBAG__) +#define __COREFOUNDATION_CFBAG__ 1 + +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef const void * (*CFBagRetainCallBack)(CFAllocatorRef allocator, const void *value); +typedef void (*CFBagReleaseCallBack)(CFAllocatorRef allocator, const void *value); +typedef CFStringRef (*CFBagCopyDescriptionCallBack)(const void *value); +typedef Boolean (*CFBagEqualCallBack)(const void *value1, const void *value2); +typedef CFHashCode (*CFBagHashCallBack)(const void *value); +typedef struct { + CFIndex version; + CFBagRetainCallBack retain; + CFBagReleaseCallBack release; + CFBagCopyDescriptionCallBack copyDescription; + CFBagEqualCallBack equal; + CFBagHashCallBack hash; +} CFBagCallBacks; + +CF_EXPORT +const CFBagCallBacks kCFTypeBagCallBacks; +CF_EXPORT +const CFBagCallBacks kCFCopyStringBagCallBacks; + +typedef void (*CFBagApplierFunction)(const void *value, void *context); + +typedef const struct __CFBag * CFBagRef; +typedef struct __CFBag * CFMutableBagRef; + +CF_EXPORT +CFTypeID CFBagGetTypeID(void); + +CF_EXPORT +CFBagRef CFBagCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFBagCallBacks *callBacks); + +CF_EXPORT +CFBagRef CFBagCreateCopy(CFAllocatorRef allocator, CFBagRef theBag); + +CF_EXPORT +CFMutableBagRef CFBagCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFBagCallBacks *callBacks); + +CF_EXPORT +CFMutableBagRef CFBagCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFBagRef theBag); + +CF_EXPORT +CFIndex CFBagGetCount(CFBagRef theBag); + +CF_EXPORT +CFIndex CFBagGetCountOfValue(CFBagRef theBag, const void *value); + +CF_EXPORT +Boolean CFBagContainsValue(CFBagRef theBag, const void *value); + +CF_EXPORT +const void *CFBagGetValue(CFBagRef theBag, const void *value); + +CF_EXPORT +Boolean CFBagGetValueIfPresent(CFBagRef theBag, const void *candidate, const void **value); + +CF_EXPORT +void CFBagGetValues(CFBagRef theBag, const void **values); + +CF_EXPORT +void CFBagApplyFunction(CFBagRef theBag, CFBagApplierFunction applier, void *context); + +CF_EXPORT +void CFBagAddValue(CFMutableBagRef theBag, const void *value); + +CF_EXPORT +void CFBagReplaceValue(CFMutableBagRef theBag, const void *value); + +CF_EXPORT +void CFBagSetValue(CFMutableBagRef theBag, const void *value); + +CF_EXPORT +void CFBagRemoveValue(CFMutableBagRef theBag, const void *value); + +CF_EXPORT +void CFBagRemoveAllValues(CFMutableBagRef theBag); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFBAG__ */ + diff --git a/include/CoreFoundation/CFBase.h b/include/CoreFoundation/CFBase.h new file mode 100644 index 0000000..ac02d9b --- /dev/null +++ b/include/CoreFoundation/CFBase.h @@ -0,0 +1,618 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBase.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFBASE__) +#define __COREFOUNDATION_CFBASE__ 1 + +#include +#include + +#if (defined(__CYGWIN32__) || defined(_WIN32)) && !defined(__WIN32__) +#define __WIN32__ 1 +#endif + +#if defined(_WIN64) && !defined(__WIN64__) +#define __WIN64__ 1 +#endif + +#if defined(__WIN64__) && !defined(__LLP64__) +#define __LLP64__ 1 +#endif + +#if defined(_MSC_VER) && defined(_M_IX86) +#define __i386__ 1 +#endif + +#if (defined(__i386__) || defined(__x86_64__)) && !defined(__LITTLE_ENDIAN__) +#define __LITTLE_ENDIAN__ 1 +#endif + +#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +#error Do not know the endianess of this architecture +#endif + +#if !__BIG_ENDIAN__ && !__LITTLE_ENDIAN__ +#error Both __BIG_ENDIAN__ and __LITTLE_ENDIAN__ cannot be false +#endif + +#if __BIG_ENDIAN__ && __LITTLE_ENDIAN__ +#error Both __BIG_ENDIAN__ and __LITTLE_ENDIAN__ cannot be true +#endif + +// Some compilers provide the capability to test if certain features are available. This macro provides a compatibility path for other compilers. +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + +// Some compilers provide the capability to test if certain attributes are available. This macro provides a compatibility path for other compilers. +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif + +#ifndef __has_extension +#define __has_extension(x) 0 +#endif + +#if defined(__GNUC__) || TARGET_OS_WIN32 +#include +#include +#endif + +#if __BLOCKS__ +#include +#endif + + #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) + #include + #endif + +#if !defined(__MACTYPES__) +#if !defined(_OS_OSTYPES_H) + typedef unsigned char Boolean; + typedef unsigned char UInt8; + typedef signed char SInt8; + typedef unsigned short UInt16; + typedef signed short SInt16; + typedef unsigned int UInt32; + typedef signed int SInt32; + typedef uint64_t UInt64; + typedef int64_t SInt64; + typedef SInt32 OSStatus; +#endif + typedef float Float32; + typedef double Float64; + typedef unsigned short UniChar; + typedef unsigned long UniCharCount; + typedef unsigned char * StringPtr; + typedef const unsigned char * ConstStringPtr; + typedef unsigned char Str255[256]; + typedef const unsigned char * ConstStr255Param; + typedef SInt16 OSErr; + typedef SInt16 RegionCode; + typedef SInt16 LangCode; + typedef SInt16 ScriptCode; + typedef UInt32 FourCharCode; + typedef FourCharCode OSType; + typedef UInt8 Byte; + typedef SInt8 SignedByte; +#endif +#if !defined(__MACTYPES__) || (defined(UNIVERSAL_INTERFACES_VERSION) && UNIVERSAL_INTERFACES_VERSION < 0x0340) + typedef UInt32 UTF32Char; + typedef UInt16 UTF16Char; + typedef UInt8 UTF8Char; +#endif + +#if !defined(CF_EXTERN_C_BEGIN) +#if defined(__cplusplus) +#define CF_EXTERN_C_BEGIN extern "C" { +#define CF_EXTERN_C_END } +#else +#define CF_EXTERN_C_BEGIN +#define CF_EXTERN_C_END +#endif +#endif + +#if TARGET_OS_WIN32 + +#if !defined(CF_EXPORT) +#if defined(CF_BUILDING_CF) && defined(__cplusplus) +#define CF_EXPORT extern "C" __declspec(dllexport) +#elif defined(CF_BUILDING_CF) && !defined(__cplusplus) +#define CF_EXPORT extern __declspec(dllexport) +#elif defined(__cplusplus) +#define CF_EXPORT extern "C" __declspec(dllimport) +#else +#define CF_EXPORT extern __declspec(dllimport) +#endif +#endif + +#else +#define CF_EXPORT extern +#endif + +CF_EXTERN_C_BEGIN + +#if !defined(NULL) +#if defined(__GNUG__) + #define NULL __null +#elif defined(__cplusplus) + #define NULL 0 +#else + #define NULL ((void *)0) +#endif +#endif + +#if !defined(TRUE) + #define TRUE 1 +#endif + +#if !defined(FALSE) + #define FALSE 0 +#endif + +#if !defined(CF_INLINE) + #if defined(__GNUC__) && (__GNUC__ == 4) && !defined(DEBUG) + #define CF_INLINE static __inline__ __attribute__((always_inline)) + #elif defined(__GNUC__) + #define CF_INLINE static __inline__ + #elif defined(__cplusplus) + #define CF_INLINE static inline + #elif defined(_MSC_VER) + #define CF_INLINE static __inline + #elif TARGET_OS_WIN32 + #define CF_INLINE static __inline__ + #endif +#endif + +#define CF_ASSUME_NONNULL_BEGIN +#define CF_ASSUME_NONNULL_END + +// Marks functions which return a CF type that needs to be released by the caller but whose names are not consistent with CoreFoundation naming rules. The recommended fix to this is to rename the functions, but this macro can be used to let the clang static analyzer know of any exceptions that cannot be fixed. +// This macro is ONLY to be used in exceptional circumstances, not to annotate functions which conform to the CoreFoundation naming rules. +#ifndef CF_RETURNS_RETAINED +#if __has_feature(attribute_cf_returns_retained) +#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) +#else +#define CF_RETURNS_RETAINED +#endif +#endif + +// Marks functions which return a CF type that may need to be retained by the caller but whose names are not consistent with CoreFoundation naming rules. The recommended fix to this is to rename the functions, but this macro can be used to let the clang static analyzer know of any exceptions that cannot be fixed. +// This macro is ONLY to be used in exceptional circumstances, not to annotate functions which conform to the CoreFoundation naming rules. +#ifndef CF_RETURNS_NOT_RETAINED +#if __has_feature(attribute_cf_returns_not_retained) +#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) +#else +#define CF_RETURNS_NOT_RETAINED +#endif +#endif + +// Marks function arguments which are released by the callee. +#ifndef CF_RELEASES_ARGUMENT +#if __has_feature(attribute_cf_consumed) +#define CF_RELEASES_ARGUMENT __attribute__((cf_consumed)) +#else +#define CF_RELEASES_ARGUMENT +#endif +#endif + +// Compatibility +#ifndef CF_CONSUMED +#if __has_feature(attribute_cf_consumed) +#define CF_CONSUMED __attribute__((cf_consumed)) +#else +#define CF_CONSUMED +#endif +#endif + +// Marks functions which cannot be used when compiling in automatic reference counting mode. +#if __has_feature(objc_arc) +#define CF_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) +#else +#define CF_AUTOMATED_REFCOUNT_UNAVAILABLE +#endif + +#ifndef CF_IMPLICIT_BRIDGING_ENABLED +#if __has_feature(arc_cf_code_audited) +#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") +#else +#define CF_IMPLICIT_BRIDGING_ENABLED +#endif +#endif + +#ifndef CF_IMPLICIT_BRIDGING_DISABLED +#if __has_feature(arc_cf_code_audited) +#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") +#else +#define CF_IMPLICIT_BRIDGING_DISABLED +#endif +#endif + +#if __has_attribute(objc_bridge) + +#ifdef __OBJC__ +@class NSArray; +@class NSAttributedString; +@class NSString; +@class NSNull; +@class NSCharacterSet; +@class NSData; +@class NSDate; +@class NSTimeZone; +@class NSDictionary; +@class NSError; +@class NSLocale; +@class NSNumber; +@class NSNumber; +@class NSSet; +@class NSURL; +#endif + +#define CF_BRIDGED_TYPE(T) __attribute__((objc_bridge(T))) +#define CF_BRIDGED_MUTABLE_TYPE(T) __attribute__((objc_bridge_mutable(T))) +#define CF_RELATED_TYPE(T,C,I) __attribute__((objc_bridge_related(T,C,I))) +#else +#define CF_BRIDGED_TYPE(T) +#define CF_BRIDGED_MUTABLE_TYPE(T) +#define CF_RELATED_TYPE(T,C,I) +#endif + + +CF_EXPORT double kCFCoreFoundationVersionNumber; + +#if TARGET_OS_MAC +#define kCFCoreFoundationVersionNumber10_0 196.40 +#define kCFCoreFoundationVersionNumber10_0_3 196.50 +#define kCFCoreFoundationVersionNumber10_1 226.00 +#define kCFCoreFoundationVersionNumber10_1_1 226.00 +/* Note the next three do not follow the usual numbering policy from the base release */ +#define kCFCoreFoundationVersionNumber10_1_2 227.20 +#define kCFCoreFoundationVersionNumber10_1_3 227.20 +#define kCFCoreFoundationVersionNumber10_1_4 227.30 +#define kCFCoreFoundationVersionNumber10_2 263.00 +#define kCFCoreFoundationVersionNumber10_2_1 263.10 +#define kCFCoreFoundationVersionNumber10_2_2 263.10 +#define kCFCoreFoundationVersionNumber10_2_3 263.30 +#define kCFCoreFoundationVersionNumber10_2_4 263.30 +#define kCFCoreFoundationVersionNumber10_2_5 263.50 +#define kCFCoreFoundationVersionNumber10_2_6 263.50 +#define kCFCoreFoundationVersionNumber10_2_7 263.50 +#define kCFCoreFoundationVersionNumber10_2_8 263.50 +#define kCFCoreFoundationVersionNumber10_3 299.00 +#define kCFCoreFoundationVersionNumber10_3_1 299.00 +#define kCFCoreFoundationVersionNumber10_3_2 299.00 +#define kCFCoreFoundationVersionNumber10_3_3 299.30 +#define kCFCoreFoundationVersionNumber10_3_4 299.31 +#define kCFCoreFoundationVersionNumber10_3_5 299.31 +#define kCFCoreFoundationVersionNumber10_3_6 299.32 +#define kCFCoreFoundationVersionNumber10_3_7 299.33 +#define kCFCoreFoundationVersionNumber10_3_8 299.33 +#define kCFCoreFoundationVersionNumber10_3_9 299.35 +#define kCFCoreFoundationVersionNumber10_4 368.00 +#define kCFCoreFoundationVersionNumber10_4_1 368.10 +#define kCFCoreFoundationVersionNumber10_4_2 368.11 +#define kCFCoreFoundationVersionNumber10_4_3 368.18 +#define kCFCoreFoundationVersionNumber10_4_4_Intel 368.26 +#define kCFCoreFoundationVersionNumber10_4_4_PowerPC 368.25 +#define kCFCoreFoundationVersionNumber10_4_5_Intel 368.26 +#define kCFCoreFoundationVersionNumber10_4_5_PowerPC 368.25 +#define kCFCoreFoundationVersionNumber10_4_6_Intel 368.26 +#define kCFCoreFoundationVersionNumber10_4_6_PowerPC 368.25 +#define kCFCoreFoundationVersionNumber10_4_7 368.27 +#define kCFCoreFoundationVersionNumber10_4_8 368.27 +#define kCFCoreFoundationVersionNumber10_4_9 368.28 +#define kCFCoreFoundationVersionNumber10_4_10 368.28 +#define kCFCoreFoundationVersionNumber10_4_11 368.31 +#define kCFCoreFoundationVersionNumber10_5 476.00 +#define kCFCoreFoundationVersionNumber10_5_1 476.00 +#define kCFCoreFoundationVersionNumber10_5_2 476.10 +#define kCFCoreFoundationVersionNumber10_5_3 476.13 +#define kCFCoreFoundationVersionNumber10_5_4 476.14 +#define kCFCoreFoundationVersionNumber10_5_5 476.15 +#define kCFCoreFoundationVersionNumber10_5_6 476.17 +#define kCFCoreFoundationVersionNumber10_5_7 476.18 +#define kCFCoreFoundationVersionNumber10_5_8 476.19 +#define kCFCoreFoundationVersionNumber10_6 550.00 +#define kCFCoreFoundationVersionNumber10_6_1 550.00 +#define kCFCoreFoundationVersionNumber10_6_2 550.13 +#define kCFCoreFoundationVersionNumber10_6_3 550.19 +#define kCFCoreFoundationVersionNumber10_6_4 550.29 +#define kCFCoreFoundationVersionNumber10_6_5 550.42 +#define kCFCoreFoundationVersionNumber10_6_6 550.42 +#define kCFCoreFoundationVersionNumber10_6_7 550.42 +#define kCFCoreFoundationVersionNumber10_6_8 550.43 +#define kCFCoreFoundationVersionNumber10_7 635.00 +#define kCFCoreFoundationVersionNumber10_7_1 635.00 +#define kCFCoreFoundationVersionNumber10_7_2 635.15 +#define kCFCoreFoundationVersionNumber10_7_3 635.19 +#define kCFCoreFoundationVersionNumber10_7_4 635.21 +#define kCFCoreFoundationVersionNumber10_7_5 635.21 +#define kCFCoreFoundationVersionNumber10_8 744.00 +#define kCFCoreFoundationVersionNumber10_8_1 744.00 +#define kCFCoreFoundationVersionNumber10_8_2 744.12 +#define kCFCoreFoundationVersionNumber10_8_3 744.18 +#define kCFCoreFoundationVersionNumber10_8_4 744.19 +#define kCFCoreFoundationVersionNumber10_9 855.11 +#define kCFCoreFoundationVersionNumber10_9_1 855.11 +#define kCFCoreFoundationVersionNumber10_9_2 855.14 +#endif + +#if TARGET_OS_IPHONE +#define kCFCoreFoundationVersionNumber_iPhoneOS_2_0 478.23 +#define kCFCoreFoundationVersionNumber_iPhoneOS_2_1 478.26 +#define kCFCoreFoundationVersionNumber_iPhoneOS_2_2 478.29 +#define kCFCoreFoundationVersionNumber_iPhoneOS_3_0 478.47 +#define kCFCoreFoundationVersionNumber_iPhoneOS_3_1 478.52 +#define kCFCoreFoundationVersionNumber_iPhoneOS_3_2 478.61 +#define kCFCoreFoundationVersionNumber_iOS_4_0 550.32 +#define kCFCoreFoundationVersionNumber_iOS_4_1 550.38 +#define kCFCoreFoundationVersionNumber_iOS_4_2 550.52 +#define kCFCoreFoundationVersionNumber_iOS_4_3 550.52 +#define kCFCoreFoundationVersionNumber_iOS_5_0 675.00 +#define kCFCoreFoundationVersionNumber_iOS_5_1 690.10 +#define kCFCoreFoundationVersionNumber_iOS_6_0 793.00 +#define kCFCoreFoundationVersionNumber_iOS_6_1 793.00 +#define kCFCoreFoundationVersionNumber_iOS_7_0 847.20 +#define kCFCoreFoundationVersionNumber_iOS_7_1 847.24 +#endif + +#if __LLP64__ +typedef unsigned long long CFTypeID; +typedef unsigned long long CFOptionFlags; +typedef unsigned long long CFHashCode; +typedef signed long long CFIndex; +#else +typedef unsigned long CFTypeID; +typedef unsigned long CFOptionFlags; +typedef unsigned long CFHashCode; +typedef signed long CFIndex; +#endif + +/* Base "type" of all "CF objects", and polymorphic functions on them */ +typedef const void * CFTypeRef; + +typedef const struct CF_BRIDGED_TYPE(NSString) __CFString * CFStringRef; +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableString) __CFString * CFMutableStringRef; + +/* + Type to mean any instance of a property list type; + currently, CFString, CFData, CFNumber, CFBoolean, CFDate, + CFArray, and CFDictionary. +*/ +typedef CFTypeRef CFPropertyListRef; + +/* Values returned from comparison functions */ +typedef CF_ENUM(CFIndex, CFComparisonResult) { + kCFCompareLessThan = -1L, + kCFCompareEqualTo = 0, + kCFCompareGreaterThan = 1 +}; + +/* A standard comparison function */ +typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context); + +/* Constant used by some functions to indicate failed searches. */ +/* This is of type CFIndex. */ +enum { + kCFNotFound = -1 +}; + + +/* Range type */ +typedef struct { + CFIndex location; + CFIndex length; +} CFRange; + +#if defined(CF_INLINE) +CF_INLINE CFRange CFRangeMake(CFIndex loc, CFIndex len) { + CFRange range; + range.location = loc; + range.length = len; + return range; +} +#else +#define CFRangeMake(LOC, LEN) __CFRangeMake(LOC, LEN) +#endif + +/* Private; do not use */ +CF_EXPORT +CFRange __CFRangeMake(CFIndex loc, CFIndex len); + + +/* Null representant */ + +typedef const struct CF_BRIDGED_TYPE(NSNull) __CFNull * CFNullRef; + +CF_EXPORT +CFTypeID CFNullGetTypeID(void); + +CF_EXPORT +const CFNullRef kCFNull; // the singleton null instance + + +/* Allocator API + + Most of the time when specifying an allocator to Create functions, the NULL + argument indicates "use the default"; this is the same as using kCFAllocatorDefault + or the return value from CFAllocatorGetDefault(). This assures that you will use + the allocator in effect at that time. +*/ +typedef const struct __CFAllocator * CFAllocatorRef; + +/* This is a synonym for NULL, if you'd rather use a named constant. */ +CF_EXPORT +const CFAllocatorRef kCFAllocatorDefault; + +/* Default system allocator; you rarely need to use this. */ +CF_EXPORT +const CFAllocatorRef kCFAllocatorSystemDefault; + +/* This allocator uses malloc(), realloc(), and free(). This should not be + generally used; stick to kCFAllocatorDefault whenever possible. This + allocator is useful as the "bytesDeallocator" in CFData or + "contentsDeallocator" in CFString where the memory was obtained as a + result of malloc() type functions. +*/ +CF_EXPORT +const CFAllocatorRef kCFAllocatorMalloc; + +/* This allocator explicitly uses the default malloc zone, returned by + malloc_default_zone(). It should only be used when an object is + safe to be allocated in non-scanned memory. + */ +CF_EXPORT +const CFAllocatorRef kCFAllocatorMallocZone; + +/* Null allocator which does nothing and allocates no memory. This allocator + is useful as the "bytesDeallocator" in CFData or "contentsDeallocator" + in CFString where the memory should not be freed. +*/ +CF_EXPORT +const CFAllocatorRef kCFAllocatorNull; + +/* Special allocator argument to CFAllocatorCreate() which means + "use the functions given in the context to allocate the allocator + itself as well". +*/ +CF_EXPORT +const CFAllocatorRef kCFAllocatorUseContext; + +typedef const void * (*CFAllocatorRetainCallBack)(const void *info); +typedef void (*CFAllocatorReleaseCallBack)(const void *info); +typedef CFStringRef (*CFAllocatorCopyDescriptionCallBack)(const void *info); +typedef void * (*CFAllocatorAllocateCallBack)(CFIndex allocSize, CFOptionFlags hint, void *info); +typedef void * (*CFAllocatorReallocateCallBack)(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info); +typedef void (*CFAllocatorDeallocateCallBack)(void *ptr, void *info); +typedef CFIndex (*CFAllocatorPreferredSizeCallBack)(CFIndex size, CFOptionFlags hint, void *info); +typedef struct { + CFIndex version; + void * info; + CFAllocatorRetainCallBack retain; + CFAllocatorReleaseCallBack release; + CFAllocatorCopyDescriptionCallBack copyDescription; + CFAllocatorAllocateCallBack allocate; + CFAllocatorReallocateCallBack reallocate; + CFAllocatorDeallocateCallBack deallocate; + CFAllocatorPreferredSizeCallBack preferredSize; +} CFAllocatorContext; + +CF_EXPORT +CFTypeID CFAllocatorGetTypeID(void); + +/* + CFAllocatorSetDefault() sets the allocator that is used in the current + thread whenever NULL is specified as an allocator argument. This means + that most, if not all allocations will go through this allocator. It + also means that any allocator set as the default needs to be ready to + deal with arbitrary memory allocation requests; in addition, the size + and number of requests will change between releases. + + An allocator set as the default will never be released, even if later + another allocator replaces it as the default. Not only is it impractical + for it to be released (as there might be caches created under the covers + that refer to the allocator), in general it's also safer and more + efficient to keep it around. + + If you wish to use a custom allocator in a context, it's best to provide + it as the argument to the various creation functions rather than setting + it as the default. Setting the default allocator is not encouraged. + + If you do set an allocator as the default, either do it for all time in + your app, or do it in a nested fashion (by restoring the previous allocator + when you exit your context). The latter might be appropriate for plug-ins + or libraries that wish to set the default allocator. +*/ +CF_EXPORT +void CFAllocatorSetDefault(CFAllocatorRef allocator); + +CF_EXPORT +CFAllocatorRef CFAllocatorGetDefault(void); + +CF_EXPORT +CFAllocatorRef CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorContext *context); + +CF_EXPORT +void *CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint); + +CF_EXPORT +void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint); + +CF_EXPORT +void CFAllocatorDeallocate(CFAllocatorRef allocator, void *ptr); + +CF_EXPORT +CFIndex CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint); + +CF_EXPORT +void CFAllocatorGetContext(CFAllocatorRef allocator, CFAllocatorContext *context); + + +/* Polymorphic CF functions */ + +CF_IMPLICIT_BRIDGING_ENABLED + +CF_EXPORT +CFTypeID CFGetTypeID(CFTypeRef cf); + +CF_EXPORT +CFStringRef CFCopyTypeIDDescription(CFTypeID type_id); + +CF_EXPORT +CFTypeRef CFRetain(CFTypeRef cf); + +CF_EXPORT +void CFRelease(CFTypeRef cf); + +CF_EXPORT +CFTypeRef CFAutorelease(CFTypeRef CF_RELEASES_ARGUMENT arg) CF_AVAILABLE(10_9, 7_0); + +CF_EXPORT +CFIndex CFGetRetainCount(CFTypeRef cf); + +CF_EXPORT +Boolean CFEqual(CFTypeRef cf1, CFTypeRef cf2); + +CF_EXPORT +CFHashCode CFHash(CFTypeRef cf); + +CF_EXPORT +CFStringRef CFCopyDescription(CFTypeRef cf); + +CF_EXPORT +CFAllocatorRef CFGetAllocator(CFTypeRef cf); + +CF_IMPLICIT_BRIDGING_DISABLED + +// This function is unavailable in ARC mode. +CF_EXPORT +CFTypeRef CFMakeCollectable(CFTypeRef cf) CF_AUTOMATED_REFCOUNT_UNAVAILABLE; + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFBASE__ */ + diff --git a/include/CoreFoundation/CFBasicHash.h b/include/CoreFoundation/CFBasicHash.h new file mode 100644 index 0000000..30a8895 --- /dev/null +++ b/include/CoreFoundation/CFBasicHash.h @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBasicHash.h + Copyright (c) 2008-2014, Apple Inc. All rights reserved. +*/ + +#include +#include +#include "CFInternal.h" + +CF_EXTERN_C_BEGIN + +struct __objcFastEnumerationStateEquivalent2 { + unsigned long state; + unsigned long *itemsPtr; + unsigned long *mutationsPtr; + unsigned long extra[5]; +}; + +enum { + __kCFBasicHashLinearHashingValue = 1, + __kCFBasicHashDoubleHashingValue = 2, + __kCFBasicHashExponentialHashingValue = 3, +}; + +enum { + kCFBasicHashHasKeys = (1UL << 0), + kCFBasicHashHasCounts = (1UL << 1), + kCFBasicHashHasHashCache = (1UL << 2), + + kCFBasicHashIntegerValues = (1UL << 6), + kCFBasicHashIntegerKeys = (1UL << 7), + + kCFBasicHashStrongValues = (1UL << 8), + kCFBasicHashStrongKeys = (1UL << 9), + + kCFBasicHashWeakValues = (1UL << 10), + kCFBasicHashWeakKeys = (1UL << 11), + + kCFBasicHashIndirectKeys = (1UL << 12), + + kCFBasicHashLinearHashing = (__kCFBasicHashLinearHashingValue << 13), // bits 13-14 + kCFBasicHashDoubleHashing = (__kCFBasicHashDoubleHashingValue << 13), + kCFBasicHashExponentialHashing = (__kCFBasicHashExponentialHashingValue << 13), + + kCFBasicHashAggressiveGrowth = (1UL << 15), +}; + +// Note that for a hash table without keys, the value is treated as the key, +// and the value should be passed in as the key for operations which take a key. + +typedef struct { + CFIndex idx; + uintptr_t weak_key; + uintptr_t weak_value; + uintptr_t count; +} CFBasicHashBucket; + +typedef struct __CFBasicHash *CFBasicHashRef; +typedef const struct __CFBasicHash *CFConstBasicHashRef; + +// Bit 6 in the CF_INFO_BITS of the CFRuntimeBase inside the CFBasicHashRef is the "is immutable" bit +CF_INLINE Boolean CFBasicHashIsMutable(CFConstBasicHashRef ht) { + return __CFBitfieldGetValue(((CFRuntimeBase *)ht)->_cfinfo[CF_INFO_BITS], 6, 6) ? false : true; +} + +CF_INLINE void CFBasicHashMakeImmutable(CFBasicHashRef ht) { + __CFBitfieldSetValue(((CFRuntimeBase *)ht)->_cfinfo[CF_INFO_BITS], 6, 6, 1); +} + + +typedef struct __CFBasicHashCallbacks CFBasicHashCallbacks; + +struct __CFBasicHashCallbacks { + uintptr_t (*retainValue)(CFAllocatorRef alloc, uintptr_t stack_value); // Return 2nd arg or new value + uintptr_t (*retainKey)(CFAllocatorRef alloc, uintptr_t stack_key); // Return 2nd arg or new key + void (*releaseValue)(CFAllocatorRef alloc, uintptr_t stack_value); + void (*releaseKey)(CFAllocatorRef alloc, uintptr_t stack_key); + 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 + Boolean (*equateKeys)(uintptr_t coll_key1, uintptr_t stack_key2); // 1st arg is in-collection key, 2nd arg is probe parameter + CFHashCode (*hashKey)(uintptr_t stack_key); + uintptr_t (*getIndirectKey)(uintptr_t coll_value); // Return key; 1st arg is in-collection value + CFStringRef (*copyValueDescription)(uintptr_t stack_value); + CFStringRef (*copyKeyDescription)(uintptr_t stack_key); +}; + +Boolean CFBasicHashHasStrongValues(CFConstBasicHashRef ht); +Boolean CFBasicHashHasStrongKeys(CFConstBasicHashRef ht); + +CFOptionFlags CFBasicHashGetFlags(CFConstBasicHashRef ht); +CFIndex CFBasicHashGetNumBuckets(CFConstBasicHashRef ht); +CFIndex CFBasicHashGetCapacity(CFConstBasicHashRef ht); +void CFBasicHashSetCapacity(CFBasicHashRef ht, CFIndex capacity); + +CFIndex CFBasicHashGetCount(CFConstBasicHashRef ht); +CFBasicHashBucket CFBasicHashGetBucket(CFConstBasicHashRef ht, CFIndex idx); +CFBasicHashBucket CFBasicHashFindBucket(CFConstBasicHashRef ht, uintptr_t stack_key); +CFIndex CFBasicHashGetCountOfKey(CFConstBasicHashRef ht, uintptr_t stack_key); +CFIndex CFBasicHashGetCountOfValue(CFConstBasicHashRef ht, uintptr_t stack_value); +Boolean CFBasicHashesAreEqual(CFConstBasicHashRef ht1, CFConstBasicHashRef ht2); +void CFBasicHashApply(CFConstBasicHashRef ht, Boolean (^block)(CFBasicHashBucket)); +void CFBasicHashApplyIndexed(CFConstBasicHashRef ht, CFRange range, Boolean (^block)(CFBasicHashBucket)); +void CFBasicHashGetElements(CFConstBasicHashRef ht, CFIndex bufferslen, uintptr_t *weak_values, uintptr_t *weak_keys); + +Boolean CFBasicHashAddValue(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t stack_value); +void CFBasicHashReplaceValue(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t stack_value); +void CFBasicHashSetValue(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t stack_value); +CFIndex CFBasicHashRemoveValue(CFBasicHashRef ht, uintptr_t stack_key); +CFIndex CFBasicHashRemoveValueAtIndex(CFBasicHashRef ht, CFIndex idx); +void CFBasicHashRemoveAllValues(CFBasicHashRef ht); + +Boolean CFBasicHashAddIntValueAndInc(CFBasicHashRef ht, uintptr_t stack_key, uintptr_t int_value); +void CFBasicHashRemoveIntValueAndDec(CFBasicHashRef ht, uintptr_t int_value); + +size_t CFBasicHashGetSize(CFConstBasicHashRef ht, Boolean total); +void CFBasicHashSuppressRC(CFBasicHashRef ht); +void CFBasicHashUnsuppressRC(CFBasicHashRef ht); + +CFStringRef CFBasicHashCopyDescription(CFConstBasicHashRef ht, Boolean detailed, CFStringRef linePrefix, CFStringRef entryLinePrefix, Boolean describeElements); + +CFTypeID CFBasicHashGetTypeID(void); + +extern Boolean __CFBasicHashEqual(CFTypeRef cf1, CFTypeRef cf2); +extern CFHashCode __CFBasicHashHash(CFTypeRef cf); +extern CFStringRef __CFBasicHashCopyDescription(CFTypeRef cf); +extern void __CFBasicHashDeallocate(CFTypeRef cf); +extern unsigned long __CFBasicHashFastEnumeration(CFConstBasicHashRef ht, struct __objcFastEnumerationStateEquivalent2 *state, void *stackbuffer, unsigned long count); + +// creation functions create mutable CFBasicHashRefs +CFBasicHashRef CFBasicHashCreate(CFAllocatorRef allocator, CFOptionFlags flags, const CFBasicHashCallbacks *cb); +CFBasicHashRef CFBasicHashCreateCopy(CFAllocatorRef allocator, CFConstBasicHashRef ht); + + +CF_EXTERN_C_END + diff --git a/include/CoreFoundation/CFBigNumber.h b/include/CoreFoundation/CFBigNumber.h new file mode 100644 index 0000000..574ad3a --- /dev/null +++ b/include/CoreFoundation/CFBigNumber.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBigNumber.h + Copyright (c) 2012-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFBIGNUMBER__) +#define __COREFOUNDATION_CFBIGNUMBER__ 1 + +#include +#include + + +// Base 1 billion number: each digit represents 0 to 999999999 +typedef struct { + uint32_t digits[5]; + int32_t sign:8; + uint32_t __:24; +} _CFBigNum; + +void _CFBigNumInitWithInt8(_CFBigNum *r, int8_t inNum); +void _CFBigNumInitWithInt16(_CFBigNum *r, int16_t inNum); +void _CFBigNumInitWithInt32(_CFBigNum *r, int32_t inNum); +void _CFBigNumInitWithInt64(_CFBigNum *r, int64_t inNum); +#ifdef __LP64__ +void _CFBigNumInitWithInt128(_CFBigNum *r, __int128_t inNum); +#endif + +void _CFBigNumInitWithUInt8(_CFBigNum *r, uint8_t inNum); +void _CFBigNumInitWithUInt16(_CFBigNum *r, uint16_t inNum); +void _CFBigNumInitWithUInt32(_CFBigNum *r, uint32_t inNum); +void _CFBigNumInitWithUInt64(_CFBigNum *r, uint64_t inNum); +#ifdef __LP64__ +void _CFBigNumInitWithUInt128(_CFBigNum *r, __uint128_t inNum); +#endif + +int8_t _CFBigNumGetInt8(const _CFBigNum *num); +int16_t _CFBigNumGetInt16(const _CFBigNum *num); +int32_t _CFBigNumGetInt32(const _CFBigNum *num); +int64_t _CFBigNumGetInt64(const _CFBigNum *num); +#ifdef __LP64__ +__int128_t _CFBigNumGetInt128(const _CFBigNum *num); +#endif + +uint8_t _CFBigNumGetUInt8(const _CFBigNum *num); +uint16_t _CFBigNumGetUInt16(const _CFBigNum *num); +uint32_t _CFBigNumGetUInt32(const _CFBigNum *num); +uint64_t _CFBigNumGetUInt64(const _CFBigNum *num); +#ifdef __LP64__ +__uint128_t _CFBigNumGetUInt128(const _CFBigNum *num); +#endif + +void _CFBigNumInitWithCFNumber(_CFBigNum *r, CFNumberRef input); +void _CFBigNumInitWithBytes(_CFBigNum *r, const void *bytes, CFNumberType type); +CFNumberRef _CFNumberCreateWithBigNum(const _CFBigNum *input); + + +CFComparisonResult _CFBigNumCompare(const _CFBigNum *a, const _CFBigNum *b); + +void _CFBigNumNeg(_CFBigNum *r, const _CFBigNum *a); +uint8_t _CFBigNumAdd(_CFBigNum *r, const _CFBigNum *a, const _CFBigNum *b); +uint8_t _CFBigNumSub(_CFBigNum *r, const _CFBigNum *a, const _CFBigNum *b); + + +void _CFBigNumToCString(const _CFBigNum *vp, Boolean leading_zeros, Boolean leading_plus, char *buffer, size_t buflen); +void _CFBigNumFromCString(_CFBigNum *r, const char *string); + +char *_CFBigNumCopyDescription(const _CFBigNum *num); // caller must free() returned ptr + + +#endif /* ! __COREFOUNDATION_CFBIGNUMBER__ */ + diff --git a/include/CoreFoundation/CFBinaryHeap.h b/include/CoreFoundation/CFBinaryHeap.h new file mode 100644 index 0000000..5724f66 --- /dev/null +++ b/include/CoreFoundation/CFBinaryHeap.h @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBinaryHeap.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ +/*! + @header CFBinaryHeap + CFBinaryHeap implements a container which stores values sorted using + a binary search algorithm. CFBinaryHeaps can be useful as priority + queues. +*/ + +#if !defined(__COREFOUNDATION_CFBINARYHEAP__) +#define __COREFOUNDATION_CFBINARYHEAP__ 1 + +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct { + CFIndex version; + void * info; + const void *(*retain)(const void *info); + void (*release)(const void *info); + CFStringRef (*copyDescription)(const void *info); +} CFBinaryHeapCompareContext; + +/*! + @typedef CFBinaryHeapCallBacks + Structure containing the callbacks for values of a CFBinaryHeap. + @field version The version number of the structure type being passed + in as a parameter to the CFBinaryHeap creation functions. + This structure is version 0. + @field retain The callback used to add a retain for the binary heap + on values as they are put into the binary heap. + This callback returns the value to use as the value in the + binary heap, which is usually the value parameter passed to + this callback, but may be a different value if a different + value should be added to the binary heap. The binary heap's + allocator is passed as the first argument. + @field release The callback used to remove a retain previously added + for the binary heap from values as they are removed from + the binary heap. The binary heap's allocator is passed as the + first argument. + @field copyDescription The callback used to create a descriptive + string representation of each value in the binary heap. This + is used by the CFCopyDescription() function. + @field compare The callback used to compare values in the binary heap for + equality in some operations. +*/ +typedef struct { + CFIndex version; + const void *(*retain)(CFAllocatorRef allocator, const void *ptr); + void (*release)(CFAllocatorRef allocator, const void *ptr); + CFStringRef (*copyDescription)(const void *ptr); + CFComparisonResult (*compare)(const void *ptr1, const void *ptr2, void *context); +} CFBinaryHeapCallBacks; + +/*! + @constant kCFStringBinaryHeapCallBacks + Predefined CFBinaryHeapCallBacks structure containing a set + of callbacks appropriate for use when the values in a CFBinaryHeap + are all CFString types. +*/ +CF_EXPORT const CFBinaryHeapCallBacks kCFStringBinaryHeapCallBacks; + +/*! + @typedef CFBinaryHeapApplierFunction + Type of the callback function used by the apply functions of + CFBinaryHeap. + @param value The current value from the binary heap. + @param context The user-defined context parameter given to the apply + function. +*/ +typedef void (*CFBinaryHeapApplierFunction)(const void *val, void *context); + +/*! + @typedef CFBinaryHeapRef + This is the type of a reference to CFBinaryHeaps. +*/ +typedef struct __CFBinaryHeap * CFBinaryHeapRef; + +/*! + @function CFBinaryHeapGetTypeID + Returns the type identifier of all CFBinaryHeap instances. +*/ +CF_EXPORT CFTypeID CFBinaryHeapGetTypeID(void); + +/*! + @function CFBinaryHeapCreate + Creates a new mutable binary heap with the given values. + @param allocator The CFAllocator which should be used to allocate + memory for the binary heap and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param capacity A hint about the number of values that will be held + by the CFBinaryHeap. Pass 0 for no hint. The implementation may + ignore this hint, or may use it to optimize various + operations. A heap's actual capacity is only limited by + address space and available memory constraints). If this + parameter is negative, the behavior is undefined. + @param callBacks A pointer to a CFBinaryHeapCallBacks structure + initialized with the callbacks for the binary heap to use on + each value in the binary heap. A copy of the contents of the + callbacks structure is made, so that a pointer to a structure + on the stack can be passed in, or can be reused for multiple + binary heap creations. If the version field of this callbacks + structure is not one of the defined ones for CFBinaryHeap, the + behavior is undefined. The retain field may be NULL, in which + case the CFBinaryHeap will do nothing to add a retain to values + as they are put into the binary heap. The release field may be + NULL, in which case the CFBinaryHeap will do nothing to remove + the binary heap's retain (if any) on the values when the + heap is destroyed or a key-value pair is removed. If the + copyDescription field is NULL, the binary heap will create a + simple description for a value. If the equal field is NULL, the + binary heap will use pointer equality to test for equality of + values. This callbacks parameter itself may be NULL, which is + treated as if a valid structure of version 0 with all fields + NULL had been passed in. Otherwise, + if any of the fields are not valid pointers to functions + of the correct type, or this parameter is not a valid + pointer to a CFBinaryHeapCallBacks callbacks structure, + the behavior is undefined. If any of the values put into the + binary heap is not one understood by one of the callback functions + the behavior when that callback function is used is undefined. + @param compareContext A pointer to a CFBinaryHeapCompareContext structure. + @result A reference to the new CFBinaryHeap. +*/ +CF_EXPORT CFBinaryHeapRef CFBinaryHeapCreate(CFAllocatorRef allocator, CFIndex capacity, const CFBinaryHeapCallBacks *callBacks, const CFBinaryHeapCompareContext *compareContext); + +/*! + @function CFBinaryHeapCreateCopy + Creates a new mutable binary heap with the values from the given binary heap. + @param allocator The CFAllocator which should be used to allocate + memory for the binary heap and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param capacity A hint about the number of values that will be held + by the CFBinaryHeap. Pass 0 for no hint. The implementation may + ignore this hint, or may use it to optimize various + operations. A heap's actual capacity is only limited by + address space and available memory constraints). + This parameter must be greater than or equal + to the count of the heap which is to be copied, or the + behavior is undefined. If this parameter is negative, the + behavior is undefined. + @param heap The binary heap which is to be copied. The values from the + binary heap are copied as pointers into the new binary heap (that is, + the values themselves are copied, not that which the values + point to, if anything). However, the values are also + retained by the new binary heap. The count of the new binary will + be the same as the given binary heap. The new binary heap uses the same + callbacks as the binary heap to be copied. If this parameter is + not a valid CFBinaryHeap, the behavior is undefined. + @result A reference to the new mutable binary heap. +*/ +CF_EXPORT CFBinaryHeapRef CFBinaryHeapCreateCopy(CFAllocatorRef allocator, CFIndex capacity, CFBinaryHeapRef heap); + +/*! + @function CFBinaryHeapGetCount + Returns the number of values currently in the binary heap. + @param heap The binary heap to be queried. If this parameter is not a valid + CFBinaryHeap, the behavior is undefined. + @result The number of values in the binary heap. +*/ +CF_EXPORT CFIndex CFBinaryHeapGetCount(CFBinaryHeapRef heap); + +/*! + @function CFBinaryHeapGetCountOfValue + Counts the number of times the given value occurs in the binary heap. + @param heap The binary heap to be searched. If this parameter is not a + valid CFBinaryHeap, the behavior is undefined. + @param value The value for which to find matches in the binary heap. The + compare() callback provided when the binary heap was created is + used to compare. If the compare() callback was NULL, pointer + equality (in C, ==) is used. If value, or any of the values + in the binary heap, are not understood by the compare() callback, + the behavior is undefined. + @result The number of times the given value occurs in the binary heap. +*/ +CF_EXPORT CFIndex CFBinaryHeapGetCountOfValue(CFBinaryHeapRef heap, const void *value); + +/*! + @function CFBinaryHeapContainsValue + Reports whether or not the value is in the binary heap. + @param heap The binary heap to be searched. If this parameter is not a + valid CFBinaryHeap, the behavior is undefined. + @param value The value for which to find matches in the binary heap. The + compare() callback provided when the binary heap was created is + used to compare. If the compare() callback was NULL, pointer + equality (in C, ==) is used. If value, or any of the values + in the binary heap, are not understood by the compare() callback, + the behavior is undefined. + @result true, if the value is in the specified binary heap, otherwise false. +*/ +CF_EXPORT Boolean CFBinaryHeapContainsValue(CFBinaryHeapRef heap, const void *value); + +/*! + @function CFBinaryHeapGetMinimum + Returns the minimum value is in the binary heap. If the heap contains several equal + minimum values, any one may be returned. + @param heap The binary heap to be searched. If this parameter is not a + valid CFBinaryHeap, the behavior is undefined. + @result A reference to the minimum value in the binary heap, or NULL if the + binary heap contains no values. +*/ +CF_EXPORT const void * CFBinaryHeapGetMinimum(CFBinaryHeapRef heap); + +/*! + @function CFBinaryHeapGetMinimumIfPresent + Returns the minimum value is in the binary heap, if present. If the heap contains several equal + minimum values, any one may be returned. + @param heap The binary heap to be searched. If this parameter is not a + valid CFBinaryHeap, the behavior is undefined. + @param value A C pointer to pointer-sized storage to be filled with the minimum value in + the binary heap. If this value is not a valid C pointer to a pointer-sized block + of storage, the result is undefined. If the result of the function is false, the value + stored at this address is undefined. + @result true, if a minimum value was found in the specified binary heap, otherwise false. +*/ +CF_EXPORT Boolean CFBinaryHeapGetMinimumIfPresent(CFBinaryHeapRef heap, const void **value); + +/*! + @function CFBinaryHeapGetValues + Fills the buffer with values from the binary heap. + @param heap The binary heap to be queried. If this parameter is not a + valid CFBinaryHeap, the behavior is undefined. + @param values A C array of pointer-sized values to be filled with + values from the binary heap. The values in the C array are ordered + from least to greatest. If this parameter is not a valid pointer to a + C array of at least CFBinaryHeapGetCount() pointers, the behavior is undefined. +*/ +CF_EXPORT void CFBinaryHeapGetValues(CFBinaryHeapRef heap, const void **values); + +/*! + @function CFBinaryHeapApplyFunction + Calls a function once for each value in the binary heap. + @param heap The binary heap to be operated upon. If this parameter is not a + valid CFBinaryHeap, the behavior is undefined. + @param applier The callback function to call once for each value in + the given binary heap. If this parameter is not a + pointer to a function of the correct prototype, the behavior + is undefined. If there are values in the binary heap which the + applier function does not expect or cannot properly apply + to, the behavior is undefined. + @param context A pointer-sized user-defined value, which is passed + as the second parameter to the applier function, but is + otherwise unused by this function. If the context is not + what is expected by the applier function, the behavior is + undefined. +*/ +CF_EXPORT void CFBinaryHeapApplyFunction(CFBinaryHeapRef heap, CFBinaryHeapApplierFunction applier, void *context); + +/*! + @function CFBinaryHeapAddValue + Adds the value to the binary heap. + @param heap The binary heap to which the value is to be added. If this parameter is not a + valid mutable CFBinaryHeap, the behavior is undefined. + @param value The value to add to the binary heap. The value is retained by + the binary heap using the retain callback provided when the binary heap + was created. If the value is not of the sort expected by the + retain callback, the behavior is undefined. +*/ +CF_EXPORT void CFBinaryHeapAddValue(CFBinaryHeapRef heap, const void *value); + +/*! + @function CFBinaryHeapRemoveMinimumValue + Removes the minimum value from the binary heap. + @param heap The binary heap from which the minimum value is to be removed. If this + parameter is not a valid mutable CFBinaryHeap, the behavior is undefined. +*/ +CF_EXPORT void CFBinaryHeapRemoveMinimumValue(CFBinaryHeapRef heap); + +/*! + @function CFBinaryHeapRemoveAllValues + Removes all the values from the binary heap, making it empty. + @param heap The binary heap from which all of the values are to be + removed. If this parameter is not a valid mutable CFBinaryHeap, + the behavior is undefined. +*/ +CF_EXPORT void CFBinaryHeapRemoveAllValues(CFBinaryHeapRef heap); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFBINARYHEAP__ */ + diff --git a/include/CoreFoundation/CFBitVector.h b/include/CoreFoundation/CFBitVector.h new file mode 100644 index 0000000..84ba382 --- /dev/null +++ b/include/CoreFoundation/CFBitVector.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBitVector.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFBITVECTOR__) +#define __COREFOUNDATION_CFBITVECTOR__ 1 + +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef UInt32 CFBit; + +typedef const struct __CFBitVector * CFBitVectorRef; +typedef struct __CFBitVector * CFMutableBitVectorRef; + +CF_EXPORT CFTypeID CFBitVectorGetTypeID(void); + +CF_EXPORT CFBitVectorRef CFBitVectorCreate(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex numBits); +CF_EXPORT CFBitVectorRef CFBitVectorCreateCopy(CFAllocatorRef allocator, CFBitVectorRef bv); +CF_EXPORT CFMutableBitVectorRef CFBitVectorCreateMutable(CFAllocatorRef allocator, CFIndex capacity); +CF_EXPORT CFMutableBitVectorRef CFBitVectorCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFBitVectorRef bv); + +CF_EXPORT CFIndex CFBitVectorGetCount(CFBitVectorRef bv); +CF_EXPORT CFIndex CFBitVectorGetCountOfBit(CFBitVectorRef bv, CFRange range, CFBit value); +CF_EXPORT Boolean CFBitVectorContainsBit(CFBitVectorRef bv, CFRange range, CFBit value); +CF_EXPORT CFBit CFBitVectorGetBitAtIndex(CFBitVectorRef bv, CFIndex idx); +CF_EXPORT void CFBitVectorGetBits(CFBitVectorRef bv, CFRange range, UInt8 *bytes); +CF_EXPORT CFIndex CFBitVectorGetFirstIndexOfBit(CFBitVectorRef bv, CFRange range, CFBit value); +CF_EXPORT CFIndex CFBitVectorGetLastIndexOfBit(CFBitVectorRef bv, CFRange range, CFBit value); + +CF_EXPORT void CFBitVectorSetCount(CFMutableBitVectorRef bv, CFIndex count); +CF_EXPORT void CFBitVectorFlipBitAtIndex(CFMutableBitVectorRef bv, CFIndex idx); +CF_EXPORT void CFBitVectorFlipBits(CFMutableBitVectorRef bv, CFRange range); +CF_EXPORT void CFBitVectorSetBitAtIndex(CFMutableBitVectorRef bv, CFIndex idx, CFBit value); +CF_EXPORT void CFBitVectorSetBits(CFMutableBitVectorRef bv, CFRange range, CFBit value); +CF_EXPORT void CFBitVectorSetAllBits(CFMutableBitVectorRef bv, CFBit value); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFBITVECTOR__ */ + diff --git a/include/CoreFoundation/CFBundle.h b/include/CoreFoundation/CFBundle.h new file mode 100644 index 0000000..4727f60 --- /dev/null +++ b/include/CoreFoundation/CFBundle.h @@ -0,0 +1,358 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBundle.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFBUNDLE__) +#define __COREFOUNDATION_CFBUNDLE__ 1 + +#include +#include +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct __CFBundle *CFBundleRef; +typedef struct __CFBundle *CFPlugInRef; + +/* ===================== Standard Info.plist keys ===================== */ +CF_EXPORT +const CFStringRef kCFBundleInfoDictionaryVersionKey; + /* The version of the Info.plist format */ +CF_EXPORT +const CFStringRef kCFBundleExecutableKey; + /* The name of the executable in this bundle, if any */ +CF_EXPORT +const CFStringRef kCFBundleIdentifierKey; + /* The bundle identifier (for CFBundleGetBundleWithIdentifier()) */ +CF_EXPORT +const CFStringRef kCFBundleVersionKey; + /* The version number of the bundle. For Mac OS 9 style version numbers (for example "2.5.3d5"), */ + /* clients can use CFBundleGetVersionNumber() instead of accessing this key directly since that */ + /* function will properly convert the version string into its compact integer representation. */ +CF_EXPORT +const CFStringRef kCFBundleDevelopmentRegionKey; + /* The name of the development language of the bundle. */ +CF_EXPORT +const CFStringRef kCFBundleNameKey; + /* The human-readable name of the bundle. This key is often found in the InfoPlist.strings since it is usually localized. */ +CF_EXPORT +const CFStringRef kCFBundleLocalizationsKey; + /* Allows an unbundled application that handles localization itself to specify which localizations it has available. */ + +/* ===================== Finding Bundles ===================== */ + +CF_EXPORT +CFBundleRef CFBundleGetMainBundle(void); + +CF_EXPORT +CFBundleRef CFBundleGetBundleWithIdentifier(CFStringRef bundleID); + /* A bundle can name itself by providing a key in the info dictionary. */ + /* This facility is meant to allow bundle-writers to get hold of their */ + /* bundle from their code without having to know where it was on the disk. */ + /* This is meant to be a replacement mechanism for +bundleForClass: users. */ + /* Note that this does not search for bundles on the disk; it will locate */ + /* only bundles already loaded or otherwise known to the current process. */ + +CF_EXPORT +CFArrayRef CFBundleGetAllBundles(void); + /* This is potentially expensive, and not thread-safe. Use with care. */ + /* Best used for debuggging or other diagnostic purposes. */ + +/* ===================== Creating Bundles ===================== */ + +CF_EXPORT +CFTypeID CFBundleGetTypeID(void); + +CF_EXPORT +CFBundleRef CFBundleCreate(CFAllocatorRef allocator, CFURLRef bundleURL); + /* Might return an existing instance with the ref-count bumped. */ + +CF_EXPORT +CFArrayRef CFBundleCreateBundlesFromDirectory(CFAllocatorRef allocator, CFURLRef directoryURL, CFStringRef bundleType); + /* Create instances for all bundles in the given directory matching the given type */ + /* (or all of them if bundleType is NULL). Instances are created using CFBundleCreate() and are not released. */ + +/* ==================== Basic Bundle Info ==================== */ + +CF_EXPORT +CFURLRef CFBundleCopyBundleURL(CFBundleRef bundle); + +CF_EXPORT +CFTypeRef CFBundleGetValueForInfoDictionaryKey(CFBundleRef bundle, CFStringRef key); + /* Returns a localized value if available, otherwise the global value. */ + /* This is the recommended function for examining the info dictionary. */ + +CF_EXPORT +CFDictionaryRef CFBundleGetInfoDictionary(CFBundleRef bundle); + /* This is the global info dictionary. Note that CFBundle may add */ + /* extra keys to the dictionary for its own use. */ + +CF_EXPORT +CFDictionaryRef CFBundleGetLocalInfoDictionary(CFBundleRef bundle); + /* This is the localized info dictionary. */ + +CF_EXPORT +void CFBundleGetPackageInfo(CFBundleRef bundle, UInt32 *packageType, UInt32 *packageCreator); + +CF_EXPORT +CFStringRef CFBundleGetIdentifier(CFBundleRef bundle); + +CF_EXPORT +UInt32 CFBundleGetVersionNumber(CFBundleRef bundle); + +CF_EXPORT +CFStringRef CFBundleGetDevelopmentRegion(CFBundleRef bundle); + +CF_EXPORT +CFURLRef CFBundleCopySupportFilesDirectoryURL(CFBundleRef bundle); + +CF_EXPORT +CFURLRef CFBundleCopyResourcesDirectoryURL(CFBundleRef bundle); + +CF_EXPORT +CFURLRef CFBundleCopyPrivateFrameworksURL(CFBundleRef bundle); + +CF_EXPORT +CFURLRef CFBundleCopySharedFrameworksURL(CFBundleRef bundle); + +CF_EXPORT +CFURLRef CFBundleCopySharedSupportURL(CFBundleRef bundle); + +CF_EXPORT +CFURLRef CFBundleCopyBuiltInPlugInsURL(CFBundleRef bundle); + +/* ------------- Basic Bundle Info without a CFBundle instance ------------- */ +/* This API is provided to enable developers to retrieve basic information */ +/* about a bundle without having to create an instance of CFBundle. */ +/* Because of caching behavior when a CFBundle instance exists, it will be faster */ +/* to actually create a CFBundle if you need to retrieve multiple pieces of info. */ +CF_EXPORT +CFDictionaryRef CFBundleCopyInfoDictionaryInDirectory(CFURLRef bundleURL); + +CF_EXPORT +Boolean CFBundleGetPackageInfoInDirectory(CFURLRef url, UInt32 *packageType, UInt32 *packageCreator); + +/* ==================== Resource Handling API ==================== */ + +CF_EXPORT +CFURLRef CFBundleCopyResourceURL(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName); + +CF_EXPORT +CFArrayRef CFBundleCopyResourceURLsOfType(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName); + +CF_EXPORT +CFStringRef CFBundleCopyLocalizedString(CFBundleRef bundle, CFStringRef key, CFStringRef value, CFStringRef tableName) CF_FORMAT_ARGUMENT(2); + +#define CFCopyLocalizedString(key, comment) \ + CFBundleCopyLocalizedString(CFBundleGetMainBundle(), (key), (key), NULL) +#define CFCopyLocalizedStringFromTable(key, tbl, comment) \ + CFBundleCopyLocalizedString(CFBundleGetMainBundle(), (key), (key), (tbl)) +#define CFCopyLocalizedStringFromTableInBundle(key, tbl, bundle, comment) \ + CFBundleCopyLocalizedString((bundle), (key), (key), (tbl)) +#define CFCopyLocalizedStringWithDefaultValue(key, tbl, bundle, value, comment) \ + CFBundleCopyLocalizedString((bundle), (key), (value), (tbl)) + +/* ------------- Resource Handling without a CFBundle instance ------------- */ +/* This API is provided to enable developers to use the CFBundle resource */ +/* searching policy without having to create an instance of CFBundle. */ +/* Because of caching behavior when a CFBundle instance exists, it will be faster */ +/* to actually create a CFBundle if you need to access several resources. */ + +CF_EXPORT +CFURLRef CFBundleCopyResourceURLInDirectory(CFURLRef bundleURL, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName); + +CF_EXPORT +CFArrayRef CFBundleCopyResourceURLsOfTypeInDirectory(CFURLRef bundleURL, CFStringRef resourceType, CFStringRef subDirName); + +/* =========== Localization-specific Resource Handling API =========== */ +/* This API allows finer-grained control over specific localizations, */ +/* as distinguished from the above API, which always uses the user's */ +/* preferred localizations for the bundle in the current app context. */ + +CF_EXPORT +CFArrayRef CFBundleCopyBundleLocalizations(CFBundleRef bundle); + /* Lists the localizations that a bundle contains. */ + +CF_EXPORT +CFArrayRef CFBundleCopyPreferredLocalizationsFromArray(CFArrayRef locArray); + /* Given an array of possible localizations, returns the one or more */ + /* of them that CFBundle would use in the current application context. */ + /* To determine the localizations that would be used for a particular */ + /* bundle in the current application context, apply this function to the */ + /* result of CFBundleCopyBundleLocalizations(). */ + +CF_EXPORT +CFArrayRef CFBundleCopyLocalizationsForPreferences(CFArrayRef locArray, CFArrayRef prefArray); + /* Given an array of possible localizations, returns the one or more of */ + /* them that CFBundle would use, without reference to the current application */ + /* context, if the user's preferred localizations were given by prefArray. */ + /* If prefArray is NULL, the current user's actual preferred localizations will */ + /* be used. This is not the same as CFBundleCopyPreferredLocalizationsFromArray(), */ + /* because that function takes the current application context into account. */ + /* To determine the localizations that another application would use, apply */ + /* this function to the result of CFBundleCopyBundleLocalizations(). */ + +CF_EXPORT +CFURLRef CFBundleCopyResourceURLForLocalization(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName, CFStringRef localizationName); + +CF_EXPORT +CFArrayRef CFBundleCopyResourceURLsOfTypeForLocalization(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName, CFStringRef localizationName); + /* The localizationName argument to CFBundleCopyResourceURLForLocalization() or */ + /* CFBundleCopyResourceURLsOfTypeForLocalization() must be identical to one of the */ + /* localizations in the bundle, as returned by CFBundleCopyBundleLocalizations(). */ + /* It is recommended that either CFBundleCopyPreferredLocalizationsFromArray() or */ + /* CFBundleCopyLocalizationsForPreferences() be used to select the localization. */ + +/* =================== Unbundled application info ===================== */ +/* This API is provided to enable developers to retrieve bundle-related */ +/* information about an application that may be bundled or unbundled. */ +CF_EXPORT +CFDictionaryRef CFBundleCopyInfoDictionaryForURL(CFURLRef url); + /* For a directory URL, this is equivalent to CFBundleCopyInfoDictionaryInDirectory(). */ + /* For a plain file URL representing an unbundled executable, this will attempt to read */ + /* an info dictionary from the (__TEXT, __info_plist) section, if it is a Mach-o file, */ + /* or from a 'plst' resource. */ + +CF_EXPORT +CFArrayRef CFBundleCopyLocalizationsForURL(CFURLRef url); + /* For a directory URL, this is equivalent to calling CFBundleCopyBundleLocalizations() */ + /* on the corresponding bundle. For a plain file URL representing an unbundled executable, */ + /* this will attempt to determine its localizations using the CFBundleLocalizations and */ + /* CFBundleDevelopmentRegion keys in the dictionary returned by CFBundleCopyInfoDictionaryForURL,*/ + /* or from a 'vers' resource if those are not present. */ + +CF_EXPORT +CFArrayRef CFBundleCopyExecutableArchitecturesForURL(CFURLRef url) CF_AVAILABLE(10_5, 2_0); + /* For a directory URL, this is equivalent to calling CFBundleCopyExecutableArchitectures() */ + /* on the corresponding bundle. For a plain file URL representing an unbundled executable, */ + /* this will return the architectures it provides, if it is a Mach-o file, or NULL otherwise. */ + +/* ==================== Primitive Code Loading API ==================== */ +/* This API abstracts the various different executable formats supported on */ +/* various platforms. It can load DYLD, CFM, or DLL shared libraries (on their */ +/* appropriate platforms) and gives a uniform API for looking up functions. */ + +CF_EXPORT +CFURLRef CFBundleCopyExecutableURL(CFBundleRef bundle); + +enum { + kCFBundleExecutableArchitectureI386 = 0x00000007, + kCFBundleExecutableArchitecturePPC = 0x00000012, + kCFBundleExecutableArchitectureX86_64 = 0x01000007, + kCFBundleExecutableArchitecturePPC64 = 0x01000012 +} CF_ENUM_AVAILABLE(10_5, 2_0); + +CF_EXPORT +CFArrayRef CFBundleCopyExecutableArchitectures(CFBundleRef bundle) CF_AVAILABLE(10_5, 2_0); + /* If the bundle's executable exists and is a Mach-o file, this function will return an array */ + /* of CFNumbers whose values are integers representing the architectures the file provides. */ + /* The values currently in use are those listed in the enum above, but others may be added */ + /* in the future. If the executable is not a Mach-o file, this function returns NULL. */ + +CF_EXPORT +Boolean CFBundlePreflightExecutable(CFBundleRef bundle, CFErrorRef *error) CF_AVAILABLE(10_5, 2_0); + /* This function will return true if the bundle is loaded, or if the bundle appears to be */ + /* loadable upon inspection. This does not mean that the bundle is definitively loadable, */ + /* since it may fail to load due to link errors or other problems not readily detectable. */ + /* If this function detects problems, it will return false, and return a CFError by reference. */ + /* It is the responsibility of the caller to release the CFError. */ + +CF_EXPORT +Boolean CFBundleLoadExecutableAndReturnError(CFBundleRef bundle, CFErrorRef *error) CF_AVAILABLE(10_5, 2_0); + /* If the bundle is already loaded, this function will return true. Otherwise, it will attempt */ + /* to load the bundle, and it will return true if that attempt succeeds. If the bundle fails */ + /* to load, this function will return false, and it will return a CFError by reference. */ + /* It is the responsibility of the caller to release the CFError. */ + +CF_EXPORT +Boolean CFBundleLoadExecutable(CFBundleRef bundle); + +CF_EXPORT +Boolean CFBundleIsExecutableLoaded(CFBundleRef bundle); + +CF_EXPORT +void CFBundleUnloadExecutable(CFBundleRef bundle); + +CF_EXPORT +void *CFBundleGetFunctionPointerForName(CFBundleRef bundle, CFStringRef functionName); + +CF_EXPORT +void CFBundleGetFunctionPointersForNames(CFBundleRef bundle, CFArrayRef functionNames, void *ftbl[]); + +CF_EXPORT +void *CFBundleGetDataPointerForName(CFBundleRef bundle, CFStringRef symbolName); + +CF_EXPORT +void CFBundleGetDataPointersForNames(CFBundleRef bundle, CFArrayRef symbolNames, void *stbl[]); + +CF_EXPORT +CFURLRef CFBundleCopyAuxiliaryExecutableURL(CFBundleRef bundle, CFStringRef executableName); + /* This function can be used to find executables other than your main */ + /* executable. This is useful, for instance, for applications that have */ + /* some command line tool that is packaged with and used by the application. */ + /* The tool can be packaged in the various platform executable directories */ + /* in the bundle and can be located with this function. This allows an */ + /* app to ship versions of the tool for each platform as it does for the */ + /* main app executable. */ + +/* ==================== Getting a bundle's plugIn ==================== */ + +CF_EXPORT +CFPlugInRef CFBundleGetPlugIn(CFBundleRef bundle); + +/* ==================== Resource Manager-Related API ==================== */ + +#if __LP64__ +typedef int CFBundleRefNum; +#else +typedef SInt16 CFBundleRefNum; +#endif + +CF_EXPORT +CFBundleRefNum CFBundleOpenBundleResourceMap(CFBundleRef bundle); + /* This function opens the non-localized and the localized resource files */ + /* (if any) for the bundle, creates and makes current a single read-only */ + /* resource map combining both, and returns a reference number for it. */ + /* If it is called multiple times, it opens the files multiple times, */ + /* and returns distinct reference numbers. */ + +CF_EXPORT +SInt32 CFBundleOpenBundleResourceFiles(CFBundleRef bundle, CFBundleRefNum *refNum, CFBundleRefNum *localizedRefNum); + /* Similar to CFBundleOpenBundleResourceMap(), except that it creates two */ + /* separate resource maps and returns reference numbers for both. */ + +CF_EXPORT +void CFBundleCloseBundleResourceMap(CFBundleRef bundle, CFBundleRefNum refNum); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFBUNDLE__ */ + diff --git a/include/CoreFoundation/CFBundlePriv.h b/include/CoreFoundation/CFBundlePriv.h new file mode 100644 index 0000000..d4feb5f --- /dev/null +++ b/include/CoreFoundation/CFBundlePriv.h @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBundlePriv.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFBUNDLEPRIV__) +#define __COREFOUNDATION_CFBUNDLEPRIV__ 1 + +#include +#include +#include +#include +#include +#include + +CF_EXTERN_C_BEGIN + +/* Finder stuff */ +CF_EXPORT +const CFStringRef _kCFBundlePackageTypeKey; +CF_EXPORT +const CFStringRef _kCFBundleSignatureKey; +CF_EXPORT +const CFStringRef _kCFBundleIconFileKey; +CF_EXPORT +const CFStringRef _kCFBundleDocumentTypesKey; +CF_EXPORT +const CFStringRef _kCFBundleURLTypesKey; + +/* Localizable Finder stuff */ +CF_EXPORT +const CFStringRef _kCFBundleDisplayNameKey; +CF_EXPORT +const CFStringRef _kCFBundleShortVersionStringKey; +CF_EXPORT +const CFStringRef _kCFBundleGetInfoStringKey; +CF_EXPORT +const CFStringRef _kCFBundleGetInfoHTMLKey; + +/* Sub-keys for CFBundleDocumentTypes dictionaries */ +CF_EXPORT +const CFStringRef _kCFBundleTypeNameKey; +CF_EXPORT +const CFStringRef _kCFBundleTypeRoleKey; +CF_EXPORT +const CFStringRef _kCFBundleTypeIconFileKey; +CF_EXPORT +const CFStringRef _kCFBundleTypeOSTypesKey; +CF_EXPORT +const CFStringRef _kCFBundleTypeExtensionsKey; +CF_EXPORT +const CFStringRef _kCFBundleTypeMIMETypesKey; + +/* Sub-keys for CFBundleURLTypes dictionaries */ +CF_EXPORT +const CFStringRef _kCFBundleURLNameKey; +CF_EXPORT +const CFStringRef _kCFBundleURLIconFileKey; +CF_EXPORT +const CFStringRef _kCFBundleURLSchemesKey; + +/* Compatibility key names */ +CF_EXPORT +const CFStringRef _kCFBundleOldExecutableKey; +CF_EXPORT +const CFStringRef _kCFBundleOldInfoDictionaryVersionKey; +CF_EXPORT +const CFStringRef _kCFBundleOldNameKey; +CF_EXPORT +const CFStringRef _kCFBundleOldIconFileKey; +CF_EXPORT +const CFStringRef _kCFBundleOldDocumentTypesKey; +CF_EXPORT +const CFStringRef _kCFBundleOldShortVersionStringKey; + +/* Compatibility CFBundleDocumentTypes key names */ +CF_EXPORT +const CFStringRef _kCFBundleOldTypeNameKey; +CF_EXPORT +const CFStringRef _kCFBundleOldTypeRoleKey; +CF_EXPORT +const CFStringRef _kCFBundleOldTypeIconFileKey; +CF_EXPORT +const CFStringRef _kCFBundleOldTypeExtensions1Key; +CF_EXPORT +const CFStringRef _kCFBundleOldTypeExtensions2Key; +CF_EXPORT +const CFStringRef _kCFBundleOldTypeOSTypesKey; + +/* For platform specification */ +CF_EXPORT +const CFStringRef _kCFBundleSupportedPlatformsKey; + +/* For Code Signing */ +CF_EXPORT +const CFStringRef _kCFBundleResourceSpecificationKey; + + +/* Functions for examining directories that may "look like" bundles */ + +CF_EXPORT +CFURLRef _CFBundleCopyBundleURLForExecutableURL(CFURLRef url); + +CF_EXPORT +Boolean _CFBundleURLLooksLikeBundle(CFURLRef url); + +CF_EXPORT +CFBundleRef _CFBundleCreateIfLooksLikeBundle(CFAllocatorRef allocator, CFURLRef url); + +CF_EXPORT +CFBundleRef _CFBundleGetMainBundleIfLooksLikeBundle(void); + +CF_EXPORT +Boolean _CFBundleMainBundleInfoDictionaryComesFromResourceFork(void); + +CF_EXPORT +CFBundleRef _CFBundleCreateWithExecutableURLIfLooksLikeBundle(CFAllocatorRef allocator, CFURLRef url); + +CF_EXPORT +CFURLRef _CFBundleCopyMainBundleExecutableURL(Boolean *looksLikeBundle); + +CF_EXPORT +CFBundleRef _CFBundleGetExistingBundleWithBundleURL(CFURLRef bundleURL); + +// This function is obsolete. +CF_EXPORT +CFArrayRef _CFBundleGetSupportedPlatforms(CFBundleRef bundle); + +CF_EXPORT +CFStringRef _CFBundleGetCurrentPlatform(void); + + +/* For Code Signing */ + +// This function is obsolete. Use CFBundleCreate instead. +CF_EXPORT +CFBundleRef _CFBundleCreateIfMightBeBundle(CFAllocatorRef allocator, CFURLRef url) CF_DEPRECATED(10_6, 10_10, 2_0, 8_0); + +// This function is for code signing only. Do not use this function. +CF_EXPORT +CFBundleRef _CFBundleCreateWithExecutableURLIfMightBeBundle(CFAllocatorRef allocator, CFURLRef url); + + +/* Functions for examining the structure of a bundle */ + +CF_EXPORT +CFURLRef _CFBundleCopyResourceForkURL(CFBundleRef bundle) CF_AVAILABLE_MAC(10_0); + +CF_EXPORT +CFURLRef _CFBundleCopyInfoPlistURL(CFBundleRef bundle); + + +/* Functions for working without a bundle instance */ + +CF_EXPORT +CFURLRef _CFBundleCopyExecutableURLInDirectory(CFURLRef url); + +CF_EXPORT +CFURLRef _CFBundleCopyOtherExecutableURLInDirectory(CFURLRef url); + + +/* Functions for dealing with localizations */ + +CF_EXPORT +void _CFBundleGetLanguageAndRegionCodes(SInt32 *languageCode, SInt32 *regionCode); +// may return -1 for either one if no code can be found + +CF_EXPORT +Boolean CFBundleGetLocalizationInfoForLocalization(CFStringRef localizationName, SInt32 *languageCode, SInt32 *regionCode, SInt32 *scriptCode, CFStringEncoding *stringEncoding); + /* Gets the appropriate language and region codes, and the default */ + /* script code and encoding, for the localization specified. */ + /* Pass NULL for the localizationName to get these values for the */ + /* single most preferred localization in the current context. */ + /* May give -1 if there is no language or region code for a particular */ + /* localization. Returns false if CFBundle has no information about */ + /* the given localization. */ + +CF_EXPORT +CFStringRef CFBundleCopyLocalizationForLocalizationInfo(SInt32 languageCode, SInt32 regionCode, SInt32 scriptCode, CFStringEncoding stringEncoding); + /* Returns the default localization for the combination of codes */ + /* specified. Pass in -1 for language, region code, or script code, or */ + /* 0xFFFF for stringEncoding, if you do not wish to specify one of these. */ + +// Get a localized string for a specific localization (including processing as strings dict file). This skips the usual cache for localized strings. +CF_EXPORT CFStringRef CFBundleCopyLocalizedStringForLocalization(CFBundleRef bundle, CFStringRef key, CFStringRef value, CFStringRef tableName, CFStringRef localizationName) CF_AVAILABLE(10_10, 8_0); + +CF_EXPORT +void _CFBundleSetDefaultLocalization(CFStringRef localizationName); + + +/* Functions for dealing specifically with CFM executables */ + +CF_EXPORT +void *_CFBundleGetCFMFunctionPointerForName(CFBundleRef bundle, CFStringRef funcName); + +CF_EXPORT +void _CFBundleGetCFMFunctionPointersForNames(CFBundleRef bundle, CFArrayRef functionNames, void *ftbl[]); + +CF_EXPORT +void _CFBundleSetCFMConnectionID(CFBundleRef bundle, void *connectionID); + + +/* Miscellaneous functions */ + +CF_EXPORT +CFStringRef _CFBundleCopyFileTypeForFileURL(CFURLRef url); + +CF_EXPORT +CFStringRef _CFBundleCopyFileTypeForFileData(CFDataRef data); + +CF_EXPORT +Boolean _CFBundleGetHasChanged(CFBundleRef bundle); + +CF_EXPORT +void _CFBundleFlushCaches(void) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXPORT +void _CFBundleFlushCachesForURL(CFURLRef url) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXPORT +void _CFBundleFlushBundleCaches(CFBundleRef bundle); // The previous two functions flush cached resource paths; this one also flushes bundle-specific caches such as the info dictionary and strings files + +CF_EXPORT +CFArrayRef _CFBundleCopyAllBundles(void); // Pending publication, the only known client of this is PowerBox. Email david_smith@apple.com before using this. + +CF_EXPORT +void _CFBundleSetStringsFilesShared(CFBundleRef bundle, Boolean flag); + +CF_EXPORT +Boolean _CFBundleGetStringsFilesShared(CFBundleRef bundle); + +CF_EXPORT +CFURLRef _CFBundleCopyFrameworkURLForExecutablePath(CFStringRef executablePath); + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +#include +CF_EXPORT +void _CFBundleSetupXPCBootstrap(xpc_object_t bootstrap) CF_AVAILABLE(10_10, 8_0); +#endif + +/* Functions deprecated as SPI */ + +CF_EXPORT +CFDictionaryRef _CFBundleGetLocalInfoDictionary(CFBundleRef bundle); // deprecated in favor of CFBundleGetLocalInfoDictionary + +CF_EXPORT +CFPropertyListRef _CFBundleGetValueForInfoKey(CFBundleRef bundle, CFStringRef key); // deprecated in favor of CFBundleGetValueForInfoDictionaryKey + +CF_EXPORT +Boolean _CFBundleGetPackageInfoInDirectory(CFAllocatorRef alloc, CFURLRef url, UInt32 *packageType, UInt32 *packageCreator); // deprecated in favor of CFBundleGetPackageInfoInDirectory + +CF_EXPORT +CFDictionaryRef _CFBundleCopyInfoDictionaryInResourceFork(CFURLRef url); // CFBundleCopyInfoDictionaryForURL is usually preferred; for the main bundle, however, no special call is necessary, since the info dictionary will automatically be available whether the app is bundled or not + +CF_EXPORT +CFURLRef _CFBundleCopyPrivateFrameworksURL(CFBundleRef bundle); // deprecated in favor of CFBundleCopyPrivateFrameworksURL + +CF_EXPORT +CFURLRef _CFBundleCopySharedFrameworksURL(CFBundleRef bundle); // deprecated in favor of CFBundleCopySharedFrameworksURL + +CF_EXPORT +CFURLRef _CFBundleCopySharedSupportURL(CFBundleRef bundle); // deprecated in favor of CFBundleCopySharedSupportURL + +CF_EXPORT +CFURLRef _CFBundleCopyBuiltInPlugInsURL(CFBundleRef bundle); // deprecated in favor of CFBundleCopyBuiltInPlugInsURL + +CF_EXPORT +CFURLRef _CFBundleCopyResourceURLForLanguage(CFBundleRef bundle, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subDirName, CFStringRef language); // deprecated in favor of CFBundleCopyResourceURLForLocalization + +CF_EXPORT +CFArrayRef _CFBundleCopyResourceURLsOfTypeForLanguage(CFBundleRef bundle, CFStringRef resourceType, CFStringRef subDirName, CFStringRef language); // deprecated in favor of CFBundleCopyResourceURLsOfTypeForLocalization + +CF_EXPORT +CFBundleRefNum _CFBundleOpenBundleResourceFork(CFBundleRef bundle); // deprecated in favor of CFBundleOpenBundleResourceMap + +CF_EXPORT +void _CFBundleCloseBundleResourceFork(CFBundleRef bundle); // deprecated in favor of CFBundleCloseBundleResourceMap + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFBUNDLEPRIV__ */ + diff --git a/include/CoreFoundation/CFBundle_BinaryTypes.h b/include/CoreFoundation/CFBundle_BinaryTypes.h new file mode 100644 index 0000000..fc3f4b4 --- /dev/null +++ b/include/CoreFoundation/CFBundle_BinaryTypes.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBundle_BinaryTypes.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFBUNDLE_BINARYTYPES__) +#define __COREFOUNDATION_CFBUNDLE_BINARYTYPES__ 1 + +CF_EXTERN_C_BEGIN + +#if DEPLOYMENT_TARGET_MACOSX +#define BINARY_SUPPORT_DYLD 1 +#define BINARY_SUPPORT_DLFCN 1 +#define USE_DYLD_PRIV 1 +#elif DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI +#define BINARY_SUPPORT_DYLD 1 +#define BINARY_SUPPORT_DLFCN 1 +#define USE_DYLD_PRIV 1 +#elif DEPLOYMENT_TARGET_WINDOWS +#define BINARY_SUPPORT_DLL 1 +#else +#error Unknown or unspecified DEPLOYMENT_TARGET +#endif + + +typedef enum { + __CFBundleUnknownBinary, + __CFBundleCFMBinary, + __CFBundleDYLDExecutableBinary, + __CFBundleDYLDBundleBinary, + __CFBundleDYLDFrameworkBinary, + __CFBundleDLLBinary, + __CFBundleUnreadableBinary, + __CFBundleNoBinary, + __CFBundleELFBinary +} __CFPBinaryType; + +/* Intended for eventual public consumption */ +typedef enum { + kCFBundleOtherExecutableType = 0, + kCFBundleMachOExecutableType, + kCFBundlePEFExecutableType, + kCFBundleELFExecutableType, + kCFBundleDLLExecutableType +} CFBundleExecutableType; + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFBUNDLE_BINARYTYPES__ */ + diff --git a/include/CoreFoundation/CFBundle_Internal.h b/include/CoreFoundation/CFBundle_Internal.h new file mode 100644 index 0000000..8cb5bec --- /dev/null +++ b/include/CoreFoundation/CFBundle_Internal.h @@ -0,0 +1,374 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBundle_Internal.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFBUNDLE_INTERNAL__) +#define __COREFOUNDATION_CFBUNDLE_INTERNAL__ 1 + +#include +#include +#include +#include +#include "CFInternal.h" +#include "CFPlugIn_Factory.h" +#include "CFBundle_BinaryTypes.h" +#include "CFByteOrder.h" + +CF_EXTERN_C_BEGIN + +#define __kCFLogBundle 3 +#define __kCFLogPlugIn 3 + +#if DEPLOYMENT_TARGET_WINDOWS +#define PLATFORM_PATH_STYLE kCFURLWindowsPathStyle +#else +#define PLATFORM_PATH_STYLE kCFURLPOSIXPathStyle +#endif + +#define CFBundleExecutableNotFoundError 4 +#define CFBundleExecutableNotLoadableError 3584 +#define CFBundleExecutableArchitectureMismatchError 3585 +#define CFBundleExecutableRuntimeMismatchError 3586 +#define CFBundleExecutableLoadError 3587 +#define CFBundleExecutableLinkError 3588 + +CF_INLINE uint32_t _CFBundleSwapInt32Conditional(uint32_t arg, Boolean swap) {return swap ? CFSwapInt32(arg) : arg;} +CF_INLINE uint32_t _CFBundleSwapInt64Conditional(uint64_t arg, Boolean swap) {return swap ? CFSwapInt64(arg) : arg;} + +// uncomment this to enable the checking for 8302591 +//#define CFBUNDLE_NO_TRAVERSE_OUTSIDE + +typedef struct __CFResourceData { + Boolean _executableLacksResourceFork; + Boolean _infoDictionaryFromResourceFork; + char _padding[2]; +} _CFResourceData; + +CF_PRIVATE _CFResourceData *__CFBundleGetResourceData(CFBundleRef bundle); + +typedef struct __CFPlugInData { + Boolean _isPlugIn; + Boolean _loadOnDemand; + Boolean _isDoingDynamicRegistration; + Boolean _unused1; + UInt32 _instanceCount; + CFMutableArrayRef _factories; +} _CFPlugInData; + +struct __CFBundle { + CFRuntimeBase _base; + + CFURLRef _url; + CFDateRef _modDate; + + __strong CFDictionaryRef _infoDict; + __strong CFDictionaryRef _localInfoDict; + CFArrayRef _searchLanguages; + + __CFPBinaryType _binaryType; + Boolean _isLoaded; + uint8_t _version; + Boolean _sharesStringsFiles; + char _padding[1]; + + /* CFM goop */ + void *_connectionCookie; + + /* DYLD goop */ + const void *_imageCookie; + const void *_moduleCookie; + + /* dlfcn goop */ + void *_handleCookie; + + /* CFM<->DYLD glue */ + CFMutableDictionaryRef _glueDict; + + /* Resource fork goop */ + _CFResourceData _resourceData; + + _CFPlugInData _plugInData; + + pthread_mutex_t _bundleLoadingLock; + + CFStringRef _executablePath; // Calculated and cached here + CFStringRef _developmentRegion; // Calculated and cached here + dispatch_once_t _developmentRegionCalculated; + + CFLock_t _lock; + + CFArrayRef _localizations; // List of localizations, including the development language fallback if required + Boolean _lookedForLocalizations; + + CFMutableDictionaryRef _resourceDirectoryContents; + + CFMutableDictionaryRef _stringTable; + + CFLock_t _queryLock; + CFMutableDictionaryRef _queryTable; + CFStringRef _bundleBasePath; + +#if defined(BINARY_SUPPORT_DLL) + HMODULE _hModule; +#endif /* BINARY_SUPPORT_DLL */ + +}; + +extern _CFPlugInData *__CFBundleGetPlugInData(CFBundleRef bundle); + +/* Private CFBundle API */ + +CF_PRIVATE CFErrorRef _CFBundleCreateErrorDebug(CFAllocatorRef allocator, CFBundleRef bundle, CFIndex code, CFStringRef debugString); + +CF_PRIVATE void _CFBundleInfoPlistProcessInfoDictionary(CFMutableDictionaryRef dict); +CF_PRIVATE Boolean _CFBundleSupportedProductName(CFStringRef fileName, CFRange searchRange); +CF_PRIVATE Boolean _CFBundleSupportedPlatformName(CFStringRef fileName, CFRange searchRange); + +CF_EXPORT CFStringRef _CFGetProductName(void); +CF_EXPORT CFStringRef _CFGetPlatformName(void); +CF_EXPORT CFStringRef _CFGetAlternatePlatformName(void); + +CF_PRIVATE void _CFBundleFlushQueryTableCache(CFBundleRef bundle); + +CF_PRIVATE SInt32 _CFBundleCurrentArchitecture(void); +CF_PRIVATE Boolean _CFBundleGetObjCImageInfo(CFBundleRef bundle, uint32_t *objcVersion, uint32_t *objcFlags); + +#if defined(BINARY_SUPPORT_DYLD) +CF_PRIVATE CFMutableDictionaryRef _CFBundleCreateInfoDictFromMainExecutable(); +CF_PRIVATE Boolean _CFBundleGrokObjCImageInfoFromMainExecutable(uint32_t *objcVersion, uint32_t *objcFlags); +#endif + +CF_PRIVATE CFStringRef _CFBundleCopyLoadedImagePathForPointer(void *p); + +// Languages and locales + +CF_PRIVATE CFArrayRef _CFBundleCopyLanguageSearchListInDirectory(CFURLRef url, uint8_t *version); +CF_PRIVATE CFArrayRef _CFBundleCopyLanguageSearchListInBundle(CFBundleRef bundle); + +CF_PRIVATE Boolean CFBundleAllowMixedLocalizations(void); + +// Misc + +extern Boolean _CFIsResourceAtURL(CFURLRef url, Boolean *isDir); +extern Boolean _CFIsResourceAtPath(CFStringRef path, Boolean *isDir); + +CF_PRIVATE uint8_t _CFBundleGetBundleVersionForURL(CFURLRef url); +extern CFDictionaryRef _CFBundleCopyInfoDictionaryInDirectory(CFAllocatorRef alloc, CFURLRef url, UInt8 *version); +extern CFDictionaryRef _CFBundleCopyInfoDictionaryInDirectoryWithVersion(CFAllocatorRef alloc, CFURLRef url, UInt8 version); +extern CFURLRef _CFBundleCopySupportFilesDirectoryURLInDirectory(CFURLRef bundleURL, UInt8 version); +extern CFURLRef _CFBundleCopyResourcesDirectoryURLInDirectory(CFURLRef bundleURL, UInt8 version); + +extern Boolean _CFBundleCouldBeBundle(CFURLRef url); +extern CFDictionaryRef _CFBundleCopyInfoDictionaryInResourceForkWithAllocator(CFAllocatorRef alloc, CFURLRef url); +CF_PRIVATE CFStringRef _CFBundleCopyExecutableName(CFBundleRef bundle, CFURLRef url, CFDictionaryRef infoDict); +#if DEPLOYMENT_TARGET_MACOSX +CF_PRIVATE CFStringRef _CFBundleCopyBundleDevelopmentRegionFromVersResource(CFBundleRef bundle); +#endif +extern CFDictionaryRef _CFBundleCopyInfoDictionaryInExecutable(CFURLRef url); +extern CFArrayRef _CFBundleCopyArchitecturesForExecutable(CFURLRef url); + +extern CFStringRef _CFBundleGetPlatformExecutablesSubdirectoryName(void); +extern CFStringRef _CFBundleGetAlternatePlatformExecutablesSubdirectoryName(void); +extern CFStringRef _CFBundleGetOtherPlatformExecutablesSubdirectoryName(void); +extern CFStringRef _CFBundleGetOtherAlternatePlatformExecutablesSubdirectoryName(void); + +extern CFStringRef _CFCreateStringFromVersionNumber(CFAllocatorRef alloc, UInt32 vers); +extern UInt32 _CFVersionNumberFromString(CFStringRef versStr); + +extern void _CFBundleScheduleForUnloading(CFBundleRef bundle); +extern void _CFBundleUnscheduleForUnloading(CFBundleRef bundle); +extern void _CFBundleUnloadScheduledBundles(void); + +CF_PRIVATE void _CFBundleAppendResourceDir(CFMutableStringRef path, uint8_t version); + +CF_PRIVATE UInt8 _CFBundleLayoutVersion(CFBundleRef bundle); + +#if defined(BINARY_SUPPORT_DYLD) +// DYLD API +extern __CFPBinaryType _CFBundleGrokBinaryType(CFURLRef executableURL); +extern CFArrayRef _CFBundleDYLDCopyLoadedImagePathsIfChanged(void); +extern CFArrayRef _CFBundleDYLDCopyLoadedImagePathsForHint(CFStringRef hint); +#if !defined(BINARY_SUPPORT_DLFCN) +extern Boolean _CFBundleDYLDCheckLoaded(CFBundleRef bundle); +extern Boolean _CFBundleDYLDLoadBundle(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error); +extern Boolean _CFBundleDYLDLoadFramework(CFBundleRef bundle, CFErrorRef *error); +extern void _CFBundleDYLDUnloadBundle(CFBundleRef bundle); +extern void *_CFBundleDYLDGetSymbolByName(CFBundleRef bundle, CFStringRef symbolName); +#endif /* !BINARY_SUPPORT_DLFCN */ +#endif /* BINARY_SUPPORT_DYLD */ + +#if defined(BINARY_SUPPORT_DLFCN) +// dlfcn API +extern Boolean _CFBundleDlfcnCheckLoaded(CFBundleRef bundle); +extern Boolean _CFBundleDlfcnPreflight(CFBundleRef bundle, CFErrorRef *error); +extern Boolean _CFBundleDlfcnLoadBundle(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error); +extern Boolean _CFBundleDlfcnLoadFramework(CFBundleRef bundle, CFErrorRef *error); +extern void _CFBundleDlfcnUnload(CFBundleRef bundle); +extern void *_CFBundleDlfcnGetSymbolByName(CFBundleRef bundle, CFStringRef symbolName); +#endif /* BINARY_SUPPORT_DLFCN */ + +#if defined(BINARY_SUPPORT_DLL) +extern Boolean _CFBundleDLLLoad(CFBundleRef bundle, CFErrorRef *error); +extern void _CFBundleDLLUnload(CFBundleRef bundle); +extern void *_CFBundleDLLGetSymbolByName(CFBundleRef bundle, CFStringRef symbolName); +#endif /* BINARY_SUPPORT_DLL */ + + +/* Private PlugIn-related CFBundle API */ + +extern Boolean _CFBundleNeedsInitPlugIn(CFBundleRef bundle); +extern void _CFBundleInitPlugIn(CFBundleRef bundle); +extern void _CFBundlePlugInLoaded(CFBundleRef bundle); +extern void _CFBundleDeallocatePlugIn(CFBundleRef bundle); + +extern void _CFPlugInWillUnload(CFPlugInRef plugIn); + +extern void _CFPlugInAddPlugInInstance(CFPlugInRef plugIn); +extern void _CFPlugInRemovePlugInInstance(CFPlugInRef plugIn); + +extern void _CFPlugInAddFactory(CFPlugInRef plugIn, _CFPFactoryRef factory); +extern void _CFPlugInRemoveFactory(CFPlugInRef plugIn, _CFPFactoryRef factory); + + +/* Strings for parsing bundle structure */ +#define _CFBundleSupportFilesDirectoryName1 CFSTR("Support Files") +#define _CFBundleSupportFilesDirectoryName2 CFSTR("Contents") +#define _CFBundleResourcesDirectoryName CFSTR("Resources") +#define _CFBundleExecutablesDirectoryName CFSTR("Executables") +#define _CFBundleNonLocalizedResourcesDirectoryName CFSTR("Non-localized Resources") + +#if DEPLOYMENT_TARGET_WINDOWS +#define _CFBundleSupportFilesDirectoryName1WithResources CFSTR("Support Files\\Resources") +#define _CFBundleSupportFilesDirectoryName2WithResources CFSTR("Contents\\Resources") +#else +#define _CFBundleSupportFilesDirectoryName1WithResources CFSTR("Support Files/Resources") +#define _CFBundleSupportFilesDirectoryName2WithResources CFSTR("Contents/Resources") +#endif + +#define _CFBundleSupportFilesURLFromBase1 CFSTR("Support%20Files/") +#define _CFBundleSupportFilesURLFromBase2 CFSTR("Contents/") +#define _CFBundleResourcesURLFromBase0 CFSTR("Resources/") +#define _CFBundleResourcesURLFromBase1 CFSTR("Support%20Files/Resources/") +#define _CFBundleResourcesURLFromBase2 CFSTR("Contents/Resources/") +#define _CFBundleAppStoreReceiptURLFromBase0 CFSTR("_MASReceipt/receipt") +#define _CFBundleAppStoreReceiptURLFromBase1 CFSTR("Support%20Files/_MASReceipt/receipt") +#define _CFBundleAppStoreReceiptURLFromBase2 CFSTR("Contents/_MASReceipt/receipt") +#define _CFBundleExecutablesURLFromBase1 CFSTR("Support%20Files/Executables/") +#define _CFBundleExecutablesURLFromBase2 CFSTR("Contents/") + +#define _CFBundleInfoURLFromBase0 CFSTR("Resources/Info.plist") +#define _CFBundleInfoURLFromBase1 CFSTR("Support%20Files/Info.plist") +#define _CFBundleInfoURLFromBase2 CFSTR("Contents/Info.plist") +#define _CFBundleInfoURLFromBase3 CFSTR("Info.plist") +#define _CFBundleInfoURLFromBaseNoExtension3 CFSTR("Info") + +#if DEPLOYMENT_TARGET_MACOSX +#define _CFBundlePlatformInfoURLFromBase0 CFSTR("Resources/Info-macos.plist") +#define _CFBundlePlatformInfoURLFromBase1 CFSTR("Support%20Files/Info-macos.plist") +#define _CFBundlePlatformInfoURLFromBase2 CFSTR("Contents/Info-macos.plist") +#define _CFBundlePlatformInfoURLFromBase3 CFSTR("Info-macos.plist") +#elif DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI +#define _CFBundlePlatformInfoURLFromBase0 CFSTR("Resources/Info-iphoneos.plist") +#define _CFBundlePlatformInfoURLFromBase1 CFSTR("Support%20Files/Info-iphoneos.plist") +#define _CFBundlePlatformInfoURLFromBase2 CFSTR("Contents/Info-iphoneos.plist") +#define _CFBundlePlatformInfoURLFromBase3 CFSTR("Info-iphoneos.plist") +#else +// No platform-specific variants in these cases +#define _CFBundlePlatformInfoURLFromBase0 _CFBundleInfoURLFromBase0 +#define _CFBundlePlatformInfoURLFromBase1 _CFBundleInfoURLFromBase1 +#define _CFBundlePlatformInfoURLFromBase2 _CFBundleInfoURLFromBase2 +#define _CFBundlePlatformInfoURLFromBase3 _CFBundleInfoURLFromBase3 +#endif + +#define _CFBundleInfoPlistName CFSTR("Info.plist") + +#if DEPLOYMENT_TARGET_MACOSX +#define _CFBundlePlatformInfoPlistName CFSTR("Info-macos.plist") +#elif DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI +#define _CFBundlePlatformInfoPlistName CFSTR("Info-iphoneos.plist") +#else +// No platform-specific Info.plist for these +#define _CFBundlePlatformInfoPlistName _CFBundleInfoPlistName +#endif + +#define _CFBundleInfoExtension CFSTR("plist") +#define _CFBundleLocalInfoName CFSTR("InfoPlist") +#define _CFBundlePkgInfoURLFromBase1 CFSTR("Support%20Files/PkgInfo") +#define _CFBundlePkgInfoURLFromBase2 CFSTR("Contents/PkgInfo") +#define _CFBundlePseudoPkgInfoURLFromBase CFSTR("PkgInfo") +#define _CFBundlePrivateFrameworksURLFromBase0 CFSTR("Frameworks/") +#define _CFBundlePrivateFrameworksURLFromBase1 CFSTR("Support%20Files/Frameworks/") +#define _CFBundlePrivateFrameworksURLFromBase2 CFSTR("Contents/Frameworks/") +#define _CFBundleSharedFrameworksURLFromBase0 CFSTR("SharedFrameworks/") +#define _CFBundleSharedFrameworksURLFromBase1 CFSTR("Support%20Files/SharedFrameworks/") +#define _CFBundleSharedFrameworksURLFromBase2 CFSTR("Contents/SharedFrameworks/") +#define _CFBundleSharedSupportURLFromBase0 CFSTR("SharedSupport/") +#define _CFBundleSharedSupportURLFromBase1 CFSTR("Support%20Files/SharedSupport/") +#define _CFBundleSharedSupportURLFromBase2 CFSTR("Contents/SharedSupport/") +#define _CFBundleBuiltInPlugInsURLFromBase0 CFSTR("PlugIns/") +#define _CFBundleBuiltInPlugInsURLFromBase1 CFSTR("Support%20Files/PlugIns/") +#define _CFBundleBuiltInPlugInsURLFromBase2 CFSTR("Contents/PlugIns/") +#define _CFBundleAlternateBuiltInPlugInsURLFromBase0 CFSTR("Plug-ins/") +#define _CFBundleAlternateBuiltInPlugInsURLFromBase1 CFSTR("Support%20Files/Plug-ins/") +#define _CFBundleAlternateBuiltInPlugInsURLFromBase2 CFSTR("Contents/Plug-ins/") + +#define _CFBundleLprojExtension CFSTR("lproj") +#define _CFBundleLprojExtensionWithDot CFSTR(".lproj") +#define _CFBundleDot CFSTR(".") +#define _CFBundleAllFiles CFSTR("_CFBAF_") +#define _CFBundleTypeIndicator CFSTR("_CFBT_") +// This directory contains resources (especially nibs) that may look up localized resources or may fall back to the development language resources +#define _CFBundleBaseDirectory CFSTR("Base") + +#define _CFBundleMacOSXPlatformName CFSTR("macos") +#define _CFBundleAlternateMacOSXPlatformName CFSTR("macosx") +#define _CFBundleiPhoneOSPlatformName CFSTR("iphoneos") +#define _CFBundleMacOS8PlatformName CFSTR("macosclassic") +#define _CFBundleAlternateMacOS8PlatformName CFSTR("macos8") +#define _CFBundleWindowsPlatformName CFSTR("windows") +#define _CFBundleHPUXPlatformName CFSTR("hpux") +#define _CFBundleSolarisPlatformName CFSTR("solaris") +#define _CFBundleLinuxPlatformName CFSTR("linux") +#define _CFBundleFreeBSDPlatformName CFSTR("freebsd") + +#define _CFBundleDefaultStringTableName CFSTR("Localizable") +#define _CFBundleStringTableType CFSTR("strings") +#define _CFBundleStringDictTableType CFSTR("stringsdict") + +#define _CFBundleUserLanguagesPreferenceName CFSTR("AppleLanguages") +#define _CFBundleOldUserLanguagesPreferenceName CFSTR("NSLanguages") + +#define _CFBundleLocalizedResourceForkFileName CFSTR("Localized") + +#define _CFBundleWindowsResourceDirectoryExtension CFSTR("resources") + +#define _CFBundleMacOSXInfoPlistPlatformName_OLD CFSTR("macos") +#define _CFBundleWindowsInfoPlistPlatformName_OLD CFSTR("win32") + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFBUNDLE_INTERNAL__ */ + diff --git a/include/CoreFoundation/CFBurstTrie.h b/include/CoreFoundation/CFBurstTrie.h new file mode 100644 index 0000000..852e022 --- /dev/null +++ b/include/CoreFoundation/CFBurstTrie.h @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFBurstTrie.h + Copyright (c) 2008-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFBURSTTRIE__) +#define __COREFOUNDATION_CFBURSTTRIE__ 1 + +#include +#include + +CF_EXTERN_C_BEGIN + +typedef struct _CFBurstTrie *CFBurstTrieRef; +typedef struct _CFBurstTrieCursor *CFBurstTrieCursorRef; + +typedef CF_OPTIONS(CFOptionFlags, CFBurstTrieOpts) { + /*! + BurstTrie Options + Use one or more of these options with CFBurstTrieCreate to tailor optimizations to the data + structure for a specific kind of application. Default is no read-write, no compression. + */ + + /* kCFBurstTrieReadOnly + When specified, the dictionary file will be serialized in an optimized format so as to be + memory-mapped on the next read. Once a trie is serialized as read-only, insertions can no + longer occur. + */ + kCFBurstTrieReadOnly = 1<<1, + + /* kCFBurstTrieBitmapCompression + This option can only be used with a read-only trie, and can be used to reduce on disk file size. + */ + kCFBurstTrieBitmapCompression = 1<<2, + + /* + kCFBurstTriePrefixCompression + This option can only be used with a read-only trie, and can be used to reduce on-disk file size. + It is important to note that any optimizations based on word frequency will be lost; recommended + for applications that often search for infrequent or uncommon words. This also allow you to use + cursor interface. + */ + kCFBurstTriePrefixCompression = 1<<3, + + /* + kCFBurstTriePrefixCompression + By default, keys at list level are sorted by weight. Use this option to sort them by key value. + This allow you to use cursor interface. + */ + kCFBurstTrieSortByKey = 1 << 4 +}; + +// Value for this option should be a CFNumber which contains an int. +#define kCFBurstTrieCreationOptionNameContainerSize CFSTR("ContainerSize") + +typedef void (*CFBurstTrieTraversalCallback)(void* context, const UInt8* key, uint32_t keyLength, uint32_t payload, Boolean *stop); + +CF_EXPORT +CFBurstTrieRef CFBurstTrieCreate() CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +CFBurstTrieRef CFBurstTrieCreateWithOptions(CFDictionaryRef options) CF_AVAILABLE(10_8, 6_0); + +CF_EXPORT +CFBurstTrieRef CFBurstTrieCreateFromFile(CFStringRef path) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +CFBurstTrieRef CFBurstTrieCreateFromMapBytes(char *mapBase) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieInsert(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, CFIndex payload) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieAdd(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, uint32_t payload) CF_AVAILABLE(10_7, 5_0); + + +CF_EXPORT +Boolean CFBurstTrieInsertCharacters(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, CFIndex payload) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieAddCharacters(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, uint32_t payload) CF_AVAILABLE(10_7, 5_0); + + +CF_EXPORT +Boolean CFBurstTrieInsertUTF8String(CFBurstTrieRef trie, UInt8 *chars, CFIndex numChars, CFIndex payload) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieAddUTF8String(CFBurstTrieRef trie, UInt8 *chars, CFIndex numChars, uint32_t payload) CF_AVAILABLE(10_7, 5_0); + + +CF_EXPORT +Boolean CFBurstTrieInsertWithWeight(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, CFIndex weight, CFIndex payload) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieAddWithWeight(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, uint32_t weight, uint32_t payload) CF_AVAILABLE(10_7, 5_0); + + +CF_EXPORT +Boolean CFBurstTrieInsertCharactersWithWeight(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, CFIndex weight, CFIndex payload) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieAddCharactersWithWeight(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, uint32_t weight, uint32_t payload) CF_AVAILABLE(10_7, 5_0); + + +CF_EXPORT +Boolean CFBurstTrieInsertUTF8StringWithWeight(CFBurstTrieRef trie, UInt8 *chars, CFIndex numChars, CFIndex weight, CFIndex payload) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieAddUTF8StringWithWeight(CFBurstTrieRef trie, UInt8 *chars, CFIndex numChars, uint32_t weight, uint32_t payload) CF_AVAILABLE(10_7, 5_0); + + +CF_EXPORT +Boolean CFBurstTrieFind(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, CFIndex *payload) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieContains(CFBurstTrieRef trie, CFStringRef term, CFRange termRange, uint32_t *payload) CF_AVAILABLE(10_7, 5_0); + + +CF_EXPORT +Boolean CFBurstTrieFindCharacters(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, CFIndex *payload) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieContainsCharacters(CFBurstTrieRef trie, UniChar *chars, CFIndex numChars, uint32_t *payload) CF_AVAILABLE(10_7, 5_0); + + +CF_EXPORT +Boolean CFBurstTrieFindUTF8String(CFBurstTrieRef trie, UInt8 *key, CFIndex length, CFIndex *payload) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieContainsUTF8String(CFBurstTrieRef trie, UInt8 *key, CFIndex length, uint32_t *payload) CF_AVAILABLE(10_7, 5_0); + + +CF_EXPORT +Boolean CFBurstTrieSerialize(CFBurstTrieRef trie, CFStringRef path, CFBurstTrieOpts opts) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFBurstTrieSerializeWithFileDescriptor(CFBurstTrieRef trie, int fd, CFBurstTrieOpts opts) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +void CFBurstTrieTraverse(CFBurstTrieRef trie, void *ctx, void (*callback)(void*, const UInt8*, uint32_t, uint32_t)) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +CFIndex CFBurstTrieGetCount(CFBurstTrieRef trie) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +CFBurstTrieRef CFBurstTrieRetain(CFBurstTrieRef trie) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +void CFBurstTrieRelease(CFBurstTrieRef trie) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +CFBurstTrieCursorRef CFBurstTrieCreateCursorForBytes(CFBurstTrieRef trie, const UInt8* bytes, CFIndex length) CF_AVAILABLE(10_8, 6_0); + +CF_EXPORT +CFBurstTrieCursorRef CFBurstTrieCursorCreateByCopy(CFBurstTrieCursorRef cursor) CF_AVAILABLE(10_8, 6_0); + +CF_EXPORT +Boolean CFBurstTrieSetCursorForBytes(CFBurstTrieRef trie, CFBurstTrieCursorRef cursor, const UInt8* bytes, CFIndex length) CF_AVAILABLE(10_8, 6_0); + +CF_EXPORT +Boolean CFBurstTrieCursorIsEqual(CFBurstTrieCursorRef lhs, CFBurstTrieCursorRef rhs) CF_AVAILABLE(10_8, 6_0); + +CF_EXPORT +Boolean CFBurstTrieCursorAdvanceForBytes(CFBurstTrieCursorRef cursor, const UInt8* bytes, CFIndex length) CF_AVAILABLE(10_8, 6_0); + +CF_EXPORT +Boolean CFBurstTrieCursorGetPayload(CFBurstTrieCursorRef cursor, uint32_t *payload) CF_AVAILABLE(10_8, 6_0); + +CF_EXPORT +void CFBurstTrieTraverseFromCursor(CFBurstTrieCursorRef cursor, void *ctx, CFBurstTrieTraversalCallback callback) CF_AVAILABLE(10_8, 6_0); + +CF_EXPORT +void CFBurstTrieCursorRelease(CFBurstTrieCursorRef cursor) CF_AVAILABLE(10_8, 6_0); + +CF_EXTERN_C_END + +#endif /* __COREFOUNDATION_CFBURSTTRIE__ */ diff --git a/include/CoreFoundation/CFByteOrder.h b/include/CoreFoundation/CFByteOrder.h new file mode 100644 index 0000000..7858572 --- /dev/null +++ b/include/CoreFoundation/CFByteOrder.h @@ -0,0 +1,323 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFByteOrder.h + Copyright (c) 1995-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFBYTEORDER__) +#define __COREFOUNDATION_CFBYTEORDER__ 1 + +#include +#if ((TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) && !defined(CF_USE_OSBYTEORDER_H) +#include +#define CF_USE_OSBYTEORDER_H 1 +#endif + +CF_EXTERN_C_BEGIN + +enum __CFByteOrder { + CFByteOrderUnknown, + CFByteOrderLittleEndian, + CFByteOrderBigEndian +}; +typedef CFIndex CFByteOrder; + +CF_INLINE CFByteOrder CFByteOrderGetCurrent(void) { +#if CF_USE_OSBYTEORDER_H + int32_t byteOrder = OSHostByteOrder(); + switch (byteOrder) { + case OSLittleEndian: return CFByteOrderLittleEndian; + case OSBigEndian: return CFByteOrderBigEndian; + default: break; + } + return CFByteOrderUnknown; +#else +#if __LITTLE_ENDIAN__ + return CFByteOrderLittleEndian; +#elif __BIG_ENDIAN__ + return CFByteOrderBigEndian; +#else + return CFByteOrderUnknown; +#endif +#endif +} + +CF_INLINE uint16_t CFSwapInt16(uint16_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapInt16(arg); +#else + uint16_t result; + result = (uint16_t)(((arg << 8) & 0xFF00) | ((arg >> 8) & 0xFF)); + return result; +#endif +} + +CF_INLINE uint32_t CFSwapInt32(uint32_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapInt32(arg); +#else + uint32_t result; + result = ((arg & 0xFF) << 24) | ((arg & 0xFF00) << 8) | ((arg >> 8) & 0xFF00) | ((arg >> 24) & 0xFF); + return result; +#endif +} + +CF_INLINE uint64_t CFSwapInt64(uint64_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapInt64(arg); +#else + union CFSwap { + uint64_t sv; + uint32_t ul[2]; + } tmp, result; + tmp.sv = arg; + result.ul[0] = CFSwapInt32(tmp.ul[1]); + result.ul[1] = CFSwapInt32(tmp.ul[0]); + return result.sv; +#endif +} + +CF_INLINE uint16_t CFSwapInt16BigToHost(uint16_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapBigToHostInt16(arg); +#elif __BIG_ENDIAN__ + return arg; +#else + return CFSwapInt16(arg); +#endif +} + +CF_INLINE uint32_t CFSwapInt32BigToHost(uint32_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapBigToHostInt32(arg); +#elif __BIG_ENDIAN__ + return arg; +#else + return CFSwapInt32(arg); +#endif +} + +CF_INLINE uint64_t CFSwapInt64BigToHost(uint64_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapBigToHostInt64(arg); +#elif __BIG_ENDIAN__ + return arg; +#else + return CFSwapInt64(arg); +#endif +} + +CF_INLINE uint16_t CFSwapInt16HostToBig(uint16_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapHostToBigInt16(arg); +#elif __BIG_ENDIAN__ + return arg; +#else + return CFSwapInt16(arg); +#endif +} + +CF_INLINE uint32_t CFSwapInt32HostToBig(uint32_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapHostToBigInt32(arg); +#elif __BIG_ENDIAN__ + return arg; +#else + return CFSwapInt32(arg); +#endif +} + +CF_INLINE uint64_t CFSwapInt64HostToBig(uint64_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapHostToBigInt64(arg); +#elif __BIG_ENDIAN__ + return arg; +#else + return CFSwapInt64(arg); +#endif +} + +CF_INLINE uint16_t CFSwapInt16LittleToHost(uint16_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapLittleToHostInt16(arg); +#elif __LITTLE_ENDIAN__ + return arg; +#else + return CFSwapInt16(arg); +#endif +} + +CF_INLINE uint32_t CFSwapInt32LittleToHost(uint32_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapLittleToHostInt32(arg); +#elif __LITTLE_ENDIAN__ + return arg; +#else + return CFSwapInt32(arg); +#endif +} + +CF_INLINE uint64_t CFSwapInt64LittleToHost(uint64_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapLittleToHostInt64(arg); +#elif __LITTLE_ENDIAN__ + return arg; +#else + return CFSwapInt64(arg); +#endif +} + +CF_INLINE uint16_t CFSwapInt16HostToLittle(uint16_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapHostToLittleInt16(arg); +#elif __LITTLE_ENDIAN__ + return arg; +#else + return CFSwapInt16(arg); +#endif +} + +CF_INLINE uint32_t CFSwapInt32HostToLittle(uint32_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapHostToLittleInt32(arg); +#elif __LITTLE_ENDIAN__ + return arg; +#else + return CFSwapInt32(arg); +#endif +} + +CF_INLINE uint64_t CFSwapInt64HostToLittle(uint64_t arg) { +#if CF_USE_OSBYTEORDER_H + return OSSwapHostToLittleInt64(arg); +#elif __LITTLE_ENDIAN__ + return arg; +#else + return CFSwapInt64(arg); +#endif +} + +typedef struct {uint32_t v;} CFSwappedFloat32; +typedef struct {uint64_t v;} CFSwappedFloat64; + +CF_INLINE CFSwappedFloat32 CFConvertFloat32HostToSwapped(Float32 arg) { + union CFSwap { + Float32 v; + CFSwappedFloat32 sv; + } result; + result.v = arg; +#if __LITTLE_ENDIAN__ + result.sv.v = CFSwapInt32(result.sv.v); +#endif + return result.sv; +} + +CF_INLINE Float32 CFConvertFloat32SwappedToHost(CFSwappedFloat32 arg) { + union CFSwap { + Float32 v; + CFSwappedFloat32 sv; + } result; + result.sv = arg; +#if __LITTLE_ENDIAN__ + result.sv.v = CFSwapInt32(result.sv.v); +#endif + return result.v; +} + +CF_INLINE CFSwappedFloat64 CFConvertFloat64HostToSwapped(Float64 arg) { + union CFSwap { + Float64 v; + CFSwappedFloat64 sv; + } result; + result.v = arg; +#if __LITTLE_ENDIAN__ + result.sv.v = CFSwapInt64(result.sv.v); +#endif + return result.sv; +} + +CF_INLINE Float64 CFConvertFloat64SwappedToHost(CFSwappedFloat64 arg) { + union CFSwap { + Float64 v; + CFSwappedFloat64 sv; + } result; + result.sv = arg; +#if __LITTLE_ENDIAN__ + result.sv.v = CFSwapInt64(result.sv.v); +#endif + return result.v; +} + +CF_INLINE CFSwappedFloat32 CFConvertFloatHostToSwapped(float arg) { + union CFSwap { + float v; + CFSwappedFloat32 sv; + } result; + result.v = arg; +#if __LITTLE_ENDIAN__ + result.sv.v = CFSwapInt32(result.sv.v); +#endif + return result.sv; +} + +CF_INLINE float CFConvertFloatSwappedToHost(CFSwappedFloat32 arg) { + union CFSwap { + float v; + CFSwappedFloat32 sv; + } result; + result.sv = arg; +#if __LITTLE_ENDIAN__ + result.sv.v = CFSwapInt32(result.sv.v); +#endif + return result.v; +} + +CF_INLINE CFSwappedFloat64 CFConvertDoubleHostToSwapped(double arg) { + union CFSwap { + double v; + CFSwappedFloat64 sv; + } result; + result.v = arg; +#if __LITTLE_ENDIAN__ + result.sv.v = CFSwapInt64(result.sv.v); +#endif + return result.sv; +} + +CF_INLINE double CFConvertDoubleSwappedToHost(CFSwappedFloat64 arg) { + union CFSwap { + double v; + CFSwappedFloat64 sv; + } result; + result.sv = arg; +#if __LITTLE_ENDIAN__ + result.sv.v = CFSwapInt64(result.sv.v); +#endif + return result.v; +} + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFBYTEORDER__ */ + diff --git a/include/CoreFoundation/CFCalendar.h b/include/CoreFoundation/CFCalendar.h new file mode 100644 index 0000000..ee684f9 --- /dev/null +++ b/include/CoreFoundation/CFCalendar.h @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFCalendar.h + Copyright (c) 2004-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFCALENDAR__) +#define __COREFOUNDATION_CFCALENDAR__ 1 + +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSCalendar) __CFCalendar * CFCalendarRef; + +CF_EXPORT +CFTypeID CFCalendarGetTypeID(void); + +CF_EXPORT +CFCalendarRef CFCalendarCopyCurrent(void); + +CF_EXPORT +CFCalendarRef CFCalendarCreateWithIdentifier(CFAllocatorRef allocator, CFStringRef identifier); + // Create a calendar. The identifiers are the kCF*Calendar + // constants in CFLocale.h. + +CF_EXPORT +CFStringRef CFCalendarGetIdentifier(CFCalendarRef calendar); + // Returns the calendar's identifier. + +CF_EXPORT +CFLocaleRef CFCalendarCopyLocale(CFCalendarRef calendar); + +CF_EXPORT +void CFCalendarSetLocale(CFCalendarRef calendar, CFLocaleRef locale); + +CF_EXPORT +CFTimeZoneRef CFCalendarCopyTimeZone(CFCalendarRef calendar); + +CF_EXPORT +void CFCalendarSetTimeZone(CFCalendarRef calendar, CFTimeZoneRef tz); + +CF_EXPORT +CFIndex CFCalendarGetFirstWeekday(CFCalendarRef calendar); + +CF_EXPORT +void CFCalendarSetFirstWeekday(CFCalendarRef calendar, CFIndex wkdy); + +CF_EXPORT +CFIndex CFCalendarGetMinimumDaysInFirstWeek(CFCalendarRef calendar); + +CF_EXPORT +void CFCalendarSetMinimumDaysInFirstWeek(CFCalendarRef calendar, CFIndex mwd); + + +typedef CF_OPTIONS(CFOptionFlags, CFCalendarUnit) { + kCFCalendarUnitEra = (1UL << 1), + kCFCalendarUnitYear = (1UL << 2), + kCFCalendarUnitMonth = (1UL << 3), + kCFCalendarUnitDay = (1UL << 4), + kCFCalendarUnitHour = (1UL << 5), + kCFCalendarUnitMinute = (1UL << 6), + kCFCalendarUnitSecond = (1UL << 7), + kCFCalendarUnitWeek CF_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0) = (1UL << 8), + kCFCalendarUnitWeekday = (1UL << 9), + kCFCalendarUnitWeekdayOrdinal = (1UL << 10), + kCFCalendarUnitQuarter CF_ENUM_AVAILABLE(10_6, 4_0) = (1UL << 11), + kCFCalendarUnitWeekOfMonth CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 12), + kCFCalendarUnitWeekOfYear CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 13), + kCFCalendarUnitYearForWeekOfYear CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 14), +}; + +CF_EXPORT +CFRange CFCalendarGetMinimumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit); + +CF_EXPORT +CFRange CFCalendarGetMaximumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit); + +CF_EXPORT +CFRange CFCalendarGetRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at); + +CF_EXPORT +CFIndex CFCalendarGetOrdinalityOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at); + +CF_EXPORT +Boolean CFCalendarGetTimeRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit, CFAbsoluteTime at, CFAbsoluteTime *startp, CFTimeInterval *tip) CF_AVAILABLE(10_5, 2_0); + +CF_EXPORT +Boolean CFCalendarComposeAbsoluteTime(CFCalendarRef calendar, /* out */ CFAbsoluteTime *at, const char *componentDesc, ...); + +CF_EXPORT +Boolean CFCalendarDecomposeAbsoluteTime(CFCalendarRef calendar, CFAbsoluteTime at, const char *componentDesc, ...); + + +enum { + kCFCalendarComponentsWrap = (1UL << 0) // option for adding +}; + +CF_EXPORT +Boolean CFCalendarAddComponents(CFCalendarRef calendar, /* inout */ CFAbsoluteTime *at, CFOptionFlags options, const char *componentDesc, ...); + +CF_EXPORT +Boolean CFCalendarGetComponentDifference(CFCalendarRef calendar, CFAbsoluteTime startingAT, CFAbsoluteTime resultAT, CFOptionFlags options, const char *componentDesc, ...); + + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFCALENDAR__ */ + diff --git a/include/CoreFoundation/CFCharacterSet.h b/include/CoreFoundation/CFCharacterSet.h new file mode 100644 index 0000000..0614e30 --- /dev/null +++ b/include/CoreFoundation/CFCharacterSet.h @@ -0,0 +1,405 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFCharacterSet.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +/*! + @header CFCharacterSet + CFCharacterSet represents a set, or a bag, of Unicode characters. + The API consists of 3 groups: + 1) creation/manipulation of CFCharacterSet instances, + 2) query of a single Unicode character membership, + and 3) bitmap representation related (reading/writing). + Conceptually, CFCharacterSet is a 136K byte bitmap array of + which each bit represents a Unicode code point. It could + contain the Unicode characters in ISO 10646 Basic Multilingual + Plane (BMP) and characters in Plane 1 through Plane 16 + accessible via surrogate paris in the Unicode Transformation + Format, 16-bit encoding form (UTF-16). In other words, it can + store values from 0x00000 to 0x10FFFF in the Unicode + Transformation Format, 32-bit encoding form (UTF-32). However, + in general, how CFCharacterSet stores the information is an + implementation detail. Note even CFData used for the external + bitmap representation rarely has 136K byte. For detailed + discussion of the external bitmap representation, refer to the + comments for CFCharacterSetCreateWithBitmapRepresentation below. + Note that the existance of non-BMP characters in a character set + does not imply the membership of the corresponding surrogate + characters. For example, a character set with U+10000 does not + match with U+D800. +*/ + +#if !defined(__COREFOUNDATION_CFCHARACTERSET__) +#define __COREFOUNDATION_CFCHARACTERSET__ 1 + +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +/*! + @typedef CFCharacterSetRef + This is the type of a reference to immutable CFCharacterSets. +*/ +typedef const struct CF_BRIDGED_TYPE(NSCharacterSet) __CFCharacterSet * CFCharacterSetRef; + +/*! + @typedef CFMutableCharacterSetRef + This is the type of a reference to mutable CFMutableCharacterSets. +*/ +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableCharacterSet) __CFCharacterSet * CFMutableCharacterSetRef; + +/*! + @typedef CFCharacterSetPredefinedSet + Type of the predefined CFCharacterSet selector values. +*/ + +typedef CF_ENUM(CFIndex, CFCharacterSetPredefinedSet) { + kCFCharacterSetControl = 1, /* Control character set (Unicode General Category Cc and Cf) */ + kCFCharacterSetWhitespace, /* Whitespace character set (Unicode General Category Zs and U0009 CHARACTER TABULATION) */ + kCFCharacterSetWhitespaceAndNewline, /* Whitespace and Newline character set (Unicode General Category Z*, U000A ~ U000D, and U0085) */ + kCFCharacterSetDecimalDigit, /* Decimal digit character set */ + kCFCharacterSetLetter, /* Letter character set (Unicode General Category L* & M*) */ + kCFCharacterSetLowercaseLetter, /* Lowercase character set (Unicode General Category Ll) */ + kCFCharacterSetUppercaseLetter, /* Uppercase character set (Unicode General Category Lu and Lt) */ + kCFCharacterSetNonBase, /* Non-base character set (Unicode General Category M*) */ + kCFCharacterSetDecomposable, /* Canonically decomposable character set */ + kCFCharacterSetAlphaNumeric, /* Alpha Numeric character set (Unicode General Category L*, M*, & N*) */ + kCFCharacterSetPunctuation, /* Punctuation character set (Unicode General Category P*) */ + kCFCharacterSetCapitalizedLetter = 13, /* Titlecase character set (Unicode General Category Lt) */ + kCFCharacterSetSymbol = 14, /* Symbol character set (Unicode General Category S*) */ + kCFCharacterSetNewline CF_ENUM_AVAILABLE(10_5, 2_0) = 15, /* Newline character set (U000A ~ U000D, U0085, U2028, and U2029) */ + kCFCharacterSetIllegal = 12/* Illegal character set */ +}; + +/*! + @function CFCharacterSetGetTypeID + Returns the type identifier of all CFCharacterSet instances. +*/ +CF_EXPORT +CFTypeID CFCharacterSetGetTypeID(void); + +/*! + @function CFCharacterSetGetPredefined + Returns a predefined CFCharacterSet instance. + @param theSetIdentifier The CFCharacterSetPredefinedSet selector + which specifies the predefined character set. If the + value is not in CFCharacterSetPredefinedSet, the behavior + is undefined. + @result A reference to the predefined immutable CFCharacterSet. + This instance is owned by CF. +*/ +CF_EXPORT +CFCharacterSetRef CFCharacterSetGetPredefined(CFCharacterSetPredefinedSet theSetIdentifier); + +/*! + @function CFCharacterSetCreateWithCharactersInRange + Creates a new immutable character set with the values from the given range. + @param alloc The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param theRange The CFRange which should be used to specify the + Unicode range the character set is filled with. It + accepts the range in 32-bit in the UTF-32 format. The + valid character point range is from 0x00000 to 0x10FFFF. + If the range is outside of the valid Unicode character + point, the behavior is undefined. + @result A reference to the new immutable CFCharacterSet. +*/ +CF_EXPORT +CFCharacterSetRef CFCharacterSetCreateWithCharactersInRange(CFAllocatorRef alloc, CFRange theRange); + +/*! + @function CFCharacterSetCreateWithCharactersInString + Creates a new immutable character set with the values in the given string. + @param alloc The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param theString The CFString which should be used to specify + the Unicode characters the character set is filled with. + If this parameter is not a valid CFString, the behavior + is undefined. + @result A reference to the new immutable CFCharacterSet. +*/ +CF_EXPORT +CFCharacterSetRef CFCharacterSetCreateWithCharactersInString(CFAllocatorRef alloc, CFStringRef theString); + +/*! + @function CFCharacterSetCreateWithBitmapRepresentation + Creates a new immutable character set with the bitmap representtion in the given data. + @param alloc The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param theData The CFData which should be used to specify the + bitmap representation of the Unicode character points + the character set is filled with. The bitmap + representation could contain all the Unicode character + range starting from BMP to Plane 16. The first 8192 bytes + of the data represent the BMP range. The BMP range 8192 + bytes can be followed by zero to sixteen 8192 byte + bitmaps, each one with the plane index byte prepended. + For example, the bitmap representing the BMP and Plane 2 + has the size of 16385 bytes (8192 bytes for BMP, 1 byte + index + 8192 bytes bitmap for Plane 2). The plane index + byte, in this case, contains the integer value two. If + this parameter is not a valid CFData or it contains a + Plane index byte outside of the valid Plane range + (1 to 16), the behavior is undefined. + @result A reference to the new immutable CFCharacterSet. +*/ +CF_EXPORT +CFCharacterSetRef CFCharacterSetCreateWithBitmapRepresentation(CFAllocatorRef alloc, CFDataRef theData); + +/*! + @function CFCharacterSetCreateInvertedSet + Creates a new immutable character set that is the invert of the specified character set. + @param alloc The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param theSet The CFCharacterSet which is to be inverted. If this + parameter is not a valid CFCharacterSet, the behavior is + undefined. + @result A reference to the new immutable CFCharacterSet. +*/ +CF_EXPORT CFCharacterSetRef CFCharacterSetCreateInvertedSet(CFAllocatorRef alloc, CFCharacterSetRef theSet); + +/*! + @function CFCharacterSetIsSupersetOfSet + Reports whether or not the character set is a superset of the character set specified as the second parameter. + @param theSet The character set to be checked for the membership of theOtherSet. + If this parameter is not a valid CFCharacterSet, the behavior is undefined. + @param theOtherset The character set to be checked whether or not it is a subset of theSet. + If this parameter is not a valid CFCharacterSet, the behavior is undefined. +*/ +CF_EXPORT Boolean CFCharacterSetIsSupersetOfSet(CFCharacterSetRef theSet, CFCharacterSetRef theOtherset); + +/*! + @function CFCharacterSetHasMemberInPlane + Reports whether or not the character set contains at least one member character in the specified plane. + @param theSet The character set to be checked for the membership. If this + parameter is not a valid CFCharacterSet, the behavior is undefined. + @param thePlane The plane number to be checked for the membership. + The valid value range is from 0 to 16. If the value is outside of the valid + plane number range, the behavior is undefined. +*/ +CF_EXPORT Boolean CFCharacterSetHasMemberInPlane(CFCharacterSetRef theSet, CFIndex thePlane); + +/*! + @function CFCharacterSetCreateMutable + Creates a new empty mutable character set. + @param allocator The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @result A reference to the new mutable CFCharacterSet. +*/ +CF_EXPORT +CFMutableCharacterSetRef CFCharacterSetCreateMutable(CFAllocatorRef alloc); + +/*! + @function CFCharacterSetCreateCopy + Creates a new character set with the values from the given character set. This function tries to compact the backing store where applicable. + @param allocator The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param theSet The CFCharacterSet which is to be copied. If this + parameter is not a valid CFCharacterSet, the behavior is + undefined. + @result A reference to the new CFCharacterSet. +*/ +CF_EXPORT +CFCharacterSetRef CFCharacterSetCreateCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet); + +/*! + @function CFCharacterSetCreateMutableCopy + Creates a new mutable character set with the values from the given character set. + @param allocator The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param theSet The CFCharacterSet which is to be copied. If this + parameter is not a valid CFCharacterSet, the behavior is + undefined. + @result A reference to the new mutable CFCharacterSet. +*/ +CF_EXPORT +CFMutableCharacterSetRef CFCharacterSetCreateMutableCopy(CFAllocatorRef alloc, CFCharacterSetRef theSet); + +/*! + @function CFCharacterSetIsCharacterMember + Reports whether or not the Unicode character is in the character set. + @param theSet The character set to be searched. If this parameter + is not a valid CFCharacterSet, the behavior is undefined. + @param theChar The Unicode character for which to test against the + character set. Note that this function takes 16-bit Unicode + character value; hence, it does not support access to the + non-BMP planes. + @result true, if the value is in the character set, otherwise false. +*/ +CF_EXPORT +Boolean CFCharacterSetIsCharacterMember(CFCharacterSetRef theSet, UniChar theChar); + +/*! + @function CFCharacterSetIsLongCharacterMember + Reports whether or not the UTF-32 character is in the character set. + @param theSet The character set to be searched. If this parameter + is not a valid CFCharacterSet, the behavior is undefined. + @param theChar The UTF-32 character for which to test against the + character set. + @result true, if the value is in the character set, otherwise false. +*/ +CF_EXPORT Boolean CFCharacterSetIsLongCharacterMember(CFCharacterSetRef theSet, UTF32Char theChar); + +/*! + @function CFCharacterSetCreateBitmapRepresentation + Creates a new immutable data with the bitmap representation from the given character set. + @param allocator The CFAllocator which should be used to allocate + memory for the array and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param theSet The CFCharacterSet which is to be used create the + bitmap representation from. Refer to the comments for + CFCharacterSetCreateWithBitmapRepresentation for the + detailed discussion of the bitmap representation format. + If this parameter is not a valid CFCharacterSet, the + behavior is undefined. + @result A reference to the new immutable CFData. +*/ +CF_EXPORT +CFDataRef CFCharacterSetCreateBitmapRepresentation(CFAllocatorRef alloc, CFCharacterSetRef theSet); + +/*! + @function CFCharacterSetAddCharactersInRange + Adds the given range to the charaacter set. + @param theSet The character set to which the range is to be added. + If this parameter is not a valid mutable CFCharacterSet, + the behavior is undefined. + @param theRange The range to add to the character set. It accepts + the range in 32-bit in the UTF-32 format. The valid + character point range is from 0x00000 to 0x10FFFF. If the + range is outside of the valid Unicode character point, + the behavior is undefined. +*/ +CF_EXPORT +void CFCharacterSetAddCharactersInRange(CFMutableCharacterSetRef theSet, CFRange theRange); + +/*! + @function CFCharacterSetRemoveCharactersInRange + Removes the given range from the charaacter set. + @param theSet The character set from which the range is to be + removed. If this parameter is not a valid mutable + CFCharacterSet, the behavior is undefined. + @param theRange The range to remove from the character set. + It accepts the range in 32-bit in the UTF-32 format. + The valid character point range is from 0x00000 to 0x10FFFF. + If the range is outside of the valid Unicode character point, + the behavior is undefined. +*/ +CF_EXPORT +void CFCharacterSetRemoveCharactersInRange(CFMutableCharacterSetRef theSet, CFRange theRange); + +/*! + @function CFCharacterSetAddCharactersInString + Adds the characters in the given string to the charaacter set. + @param theSet The character set to which the characters in the + string are to be added. If this parameter is not a + valid mutable CFCharacterSet, the behavior is undefined. + @param theString The string to add to the character set. + If this parameter is not a valid CFString, the behavior + is undefined. +*/ +CF_EXPORT +void CFCharacterSetAddCharactersInString(CFMutableCharacterSetRef theSet, CFStringRef theString); + +/*! + @function CFCharacterSetRemoveCharactersInString + Removes the characters in the given string from the charaacter set. + @param theSet The character set from which the characters in the + string are to be remove. If this parameter is not a + valid mutable CFCharacterSet, the behavior is undefined. + @param theString The string to remove from the character set. + If this parameter is not a valid CFString, the behavior + is undefined. +*/ +CF_EXPORT +void CFCharacterSetRemoveCharactersInString(CFMutableCharacterSetRef theSet, CFStringRef theString); + +/*! + @function CFCharacterSetUnion + Forms the union with the given character set. + @param theSet The destination character set into which the + union of the two character sets is stored. If this + parameter is not a valid mutable CFCharacterSet, the + behavior is undefined. + @param theOtherSet The character set with which the union is + formed. If this parameter is not a valid CFCharacterSet, + the behavior is undefined. +*/ +CF_EXPORT +void CFCharacterSetUnion(CFMutableCharacterSetRef theSet, CFCharacterSetRef theOtherSet); + +/*! + @function CFCharacterSetIntersect + Forms the intersection with the given character set. + @param theSet The destination character set into which the + intersection of the two character sets is stored. + If this parameter is not a valid mutable CFCharacterSet, + the behavior is undefined. + @param theOtherSet The character set with which the intersection + is formed. If this parameter is not a valid CFCharacterSet, + the behavior is undefined. +*/ +CF_EXPORT +void CFCharacterSetIntersect(CFMutableCharacterSetRef theSet, CFCharacterSetRef theOtherSet); + +/*! + @function CFCharacterSetInvert + Inverts the content of the given character set. + @param theSet The character set to be inverted. + If this parameter is not a valid mutable CFCharacterSet, + the behavior is undefined. +*/ +CF_EXPORT +void CFCharacterSetInvert(CFMutableCharacterSetRef theSet); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFCHARACTERSET__ */ + diff --git a/include/CoreFoundation/CFCharacterSetPriv.h b/include/CoreFoundation/CFCharacterSetPriv.h new file mode 100644 index 0000000..0758b90 --- /dev/null +++ b/include/CoreFoundation/CFCharacterSetPriv.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFCharacterSetPriv.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFCHARACTERSETPRIV__) +#define __COREFOUNDATION_CFCHARACTERSETPRIV__ 1 + +#include + +CF_EXTERN_C_BEGIN + +/*! + @function CFCharacterSetIsSurrogateHighCharacter + Reports whether or not the character is a high surrogate. + @param character The character to be checked. + @result true, if character is a high surrogate, otherwise false. +*/ +CF_INLINE Boolean CFCharacterSetIsSurrogateHighCharacter(UniChar character) { + return ((character >= 0xD800UL) && (character <= 0xDBFFUL) ? true : false); +} + +/*! + @function CFCharacterSetIsSurrogateLowCharacter + Reports whether or not the character is a low surrogate. + @param character The character to be checked. + @result true, if character is a low surrogate, otherwise false. +*/ +CF_INLINE Boolean CFCharacterSetIsSurrogateLowCharacter(UniChar character) { + return ((character >= 0xDC00UL) && (character <= 0xDFFFUL) ? true : false); +} + +/*! + @function CFCharacterSetGetLongCharacterForSurrogatePair + Returns the UTF-32 value corresponding to the surrogate pair passed in. + @param surrogateHigh The high surrogate character. If this parameter + is not a valid high surrogate character, the behavior is undefined. + @param surrogateLow The low surrogate character. If this parameter + is not a valid low surrogate character, the behavior is undefined. + @result The UTF-32 value for the surrogate pair. +*/ +CF_INLINE UTF32Char CFCharacterSetGetLongCharacterForSurrogatePair(UniChar surrogateHigh, UniChar surrogateLow) { + return (UTF32Char)(((surrogateHigh - 0xD800UL) << 10) + (surrogateLow - 0xDC00UL) + 0x0010000UL); +} + +/* Check to see if the character represented by the surrogate pair surrogateHigh & surrogateLow is in the chraracter set */ +CF_EXPORT Boolean CFCharacterSetIsSurrogatePairMember(CFCharacterSetRef theSet, UniChar surrogateHigh, UniChar surrogateLow) ; + +/* Keyed-coding support +*/ +typedef CF_ENUM(CFIndex, CFCharacterSetKeyedCodingType) { + kCFCharacterSetKeyedCodingTypeBitmap = 1, + kCFCharacterSetKeyedCodingTypeBuiltin = 2, + kCFCharacterSetKeyedCodingTypeRange = 3, + kCFCharacterSetKeyedCodingTypeString = 4, + kCFCharacterSetKeyedCodingTypeBuiltinAndBitmap = 5 +}; + +CF_EXPORT CFCharacterSetKeyedCodingType _CFCharacterSetGetKeyedCodingType(CFCharacterSetRef cset); +CF_EXPORT CFCharacterSetPredefinedSet _CFCharacterSetGetKeyedCodingBuiltinType(CFCharacterSetRef cset); +CF_EXPORT CFRange _CFCharacterSetGetKeyedCodingRange(CFCharacterSetRef cset); +CF_EXPORT CFStringRef _CFCharacterSetCreateKeyedCodingString(CFCharacterSetRef cset); +CF_EXPORT bool _CFCharacterSetIsInverted(CFCharacterSetRef cset); +CF_EXPORT void _CFCharacterSetSetIsInverted(CFCharacterSetRef cset, bool flag); + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFCHARACTERSETPRIV__ */ + diff --git a/include/CoreFoundation/CFData.h b/include/CoreFoundation/CFData.h new file mode 100644 index 0000000..ee436ca --- /dev/null +++ b/include/CoreFoundation/CFData.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFData.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFDATA__) +#define __COREFOUNDATION_CFDATA__ 1 + +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef const struct CF_BRIDGED_TYPE(NSData) __CFData * CFDataRef; +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableData) __CFData * CFMutableDataRef; + +CF_EXPORT +CFTypeID CFDataGetTypeID(void); + +CF_EXPORT +CFDataRef CFDataCreate(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex length); + +CF_EXPORT +CFDataRef CFDataCreateWithBytesNoCopy(CFAllocatorRef allocator, const UInt8 *bytes, CFIndex length, CFAllocatorRef bytesDeallocator); + /* Pass kCFAllocatorNull as bytesDeallocator to assure the bytes aren't freed */ + +CF_EXPORT +CFDataRef CFDataCreateCopy(CFAllocatorRef allocator, CFDataRef theData); + +CF_EXPORT +CFMutableDataRef CFDataCreateMutable(CFAllocatorRef allocator, CFIndex capacity); + +CF_EXPORT +CFMutableDataRef CFDataCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDataRef theData); + +CF_EXPORT +CFIndex CFDataGetLength(CFDataRef theData); + +CF_EXPORT +const UInt8 *CFDataGetBytePtr(CFDataRef theData); + +CF_EXPORT +UInt8 *CFDataGetMutableBytePtr(CFMutableDataRef theData); + +CF_EXPORT +void CFDataGetBytes(CFDataRef theData, CFRange range, UInt8 *buffer); + +CF_EXPORT +void CFDataSetLength(CFMutableDataRef theData, CFIndex length); + +CF_EXPORT +void CFDataIncreaseLength(CFMutableDataRef theData, CFIndex extraLength); + +CF_EXPORT +void CFDataAppendBytes(CFMutableDataRef theData, const UInt8 *bytes, CFIndex length); + +CF_EXPORT +void CFDataReplaceBytes(CFMutableDataRef theData, CFRange range, const UInt8 *newBytes, CFIndex newLength); + +CF_EXPORT +void CFDataDeleteBytes(CFMutableDataRef theData, CFRange range); + +typedef CF_OPTIONS(CFOptionFlags, CFDataSearchFlags) { + kCFDataSearchBackwards = 1UL << 0, + kCFDataSearchAnchored = 1UL << 1 +} CF_ENUM_AVAILABLE(10_6, 4_0); + +CF_EXPORT +CFRange CFDataFind(CFDataRef theData, CFDataRef dataToFind, CFRange searchRange, CFDataSearchFlags compareOptions) CF_AVAILABLE(10_6, 4_0); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFDATA__ */ + diff --git a/include/CoreFoundation/CFDate.h b/include/CoreFoundation/CFDate.h new file mode 100644 index 0000000..98767f9 --- /dev/null +++ b/include/CoreFoundation/CFDate.h @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFDate.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFDATE__) +#define __COREFOUNDATION_CFDATE__ 1 + +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef double CFTimeInterval; +typedef CFTimeInterval CFAbsoluteTime; +/* absolute time is the time interval since the reference date */ +/* the reference date (epoch) is 00:00:00 1 January 2001. */ + +CF_EXPORT +CFAbsoluteTime CFAbsoluteTimeGetCurrent(void); + +CF_EXPORT +const CFTimeInterval kCFAbsoluteTimeIntervalSince1970; +CF_EXPORT +const CFTimeInterval kCFAbsoluteTimeIntervalSince1904; + +typedef const struct CF_BRIDGED_TYPE(NSDate) __CFDate * CFDateRef; + +CF_EXPORT +CFTypeID CFDateGetTypeID(void); + +CF_EXPORT +CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at); + +CF_EXPORT +CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate); + +CF_EXPORT +CFTimeInterval CFDateGetTimeIntervalSinceDate(CFDateRef theDate, CFDateRef otherDate); + +CF_EXPORT +CFComparisonResult CFDateCompare(CFDateRef theDate, CFDateRef otherDate, void *context); + +CF_IMPLICIT_BRIDGING_DISABLED + +typedef const struct CF_BRIDGED_TYPE(NSTimeZone) __CFTimeZone * CFTimeZoneRef; + + +#if !defined(CF_CALENDAR_ENUM_DEPRECATED) +#define CF_CALENDAR_ENUM_DEPRECATED(A, B, C, D, ...) CF_ENUM_DEPRECATED(A, B, C, D, __VA_ARGS__) +#define CF_CALENDAR_DEPRECATED(A, B, C, D, ...) CF_DEPRECATED(A, B, C, D, __VA_ARGS__) +#endif + +typedef struct { + SInt32 year; + SInt8 month; + SInt8 day; + SInt8 hour; + SInt8 minute; + double second; +} CFGregorianDate CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); + +typedef struct { + SInt32 years; + SInt32 months; + SInt32 days; + SInt32 hours; + SInt32 minutes; + double seconds; +} CFGregorianUnits CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); + +typedef CF_OPTIONS(CFOptionFlags, CFGregorianUnitFlags) { + kCFGregorianUnitsYears CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 0), + kCFGregorianUnitsMonths CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 1), + kCFGregorianUnitsDays CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 2), + kCFGregorianUnitsHours CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 3), + kCFGregorianUnitsMinutes CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 4), + kCFGregorianUnitsSeconds CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = (1UL << 5), + kCFGregorianAllUnits CF_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead") = 0x00FFFFFF +}; + +CF_EXPORT +Boolean CFGregorianDateIsValid(CFGregorianDate gdate, CFOptionFlags unitFlags) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); + +CF_EXPORT +CFAbsoluteTime CFGregorianDateGetAbsoluteTime(CFGregorianDate gdate, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); + +CF_EXPORT +CFGregorianDate CFAbsoluteTimeGetGregorianDate(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); + +CF_EXPORT +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"); + +CF_EXPORT +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"); + +CF_EXPORT +SInt32 CFAbsoluteTimeGetDayOfWeek(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); + +CF_EXPORT +SInt32 CFAbsoluteTimeGetDayOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); + +CF_EXPORT +SInt32 CFAbsoluteTimeGetWeekOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) CF_CALENDAR_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use CFCalendar or NSCalendar API instead"); + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFDATE__ */ + diff --git a/include/CoreFoundation/CFDateFormatter.h b/include/CoreFoundation/CFDateFormatter.h new file mode 100644 index 0000000..892aee6 --- /dev/null +++ b/include/CoreFoundation/CFDateFormatter.h @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFDateFormatter.h + Copyright (c) 2003-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFDATEFORMATTER__) +#define __COREFOUNDATION_CFDATEFORMATTER__ 1 + +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct __CFDateFormatter *CFDateFormatterRef; + +// CFDateFormatters are not thread-safe. Do not use one from multiple threads! + +CF_EXPORT +CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator, CFStringRef tmplate, CFOptionFlags options, CFLocaleRef locale) CF_AVAILABLE(10_6, 4_0); + // no options defined, pass 0 for now + +CF_EXPORT +CFTypeID CFDateFormatterGetTypeID(void); + +typedef CF_ENUM(CFIndex, CFDateFormatterStyle) { // date and time format styles + kCFDateFormatterNoStyle = 0, + kCFDateFormatterShortStyle = 1, + kCFDateFormatterMediumStyle = 2, + kCFDateFormatterLongStyle = 3, + kCFDateFormatterFullStyle = 4 +}; + +// The exact formatted result for these date and time styles depends on the +// locale, but generally: +// Short is completely numeric, such as "12/13/52" or "3:30pm" +// Medium is longer, such as "Jan 12, 1952" +// Long is longer, such as "January 12, 1952" or "3:30:32pm" +// Full is pretty complete; e.g. "Tuesday, April 12, 1952 AD" or "3:30:42pm PST" +// The specifications though are left fuzzy, in part simply because a user's +// preference choices may affect the output, and also the results may change +// from one OS release to another. To produce an exactly formatted date you +// should not rely on styles and localization, but set the format string and +// use nothing but numbers. + +CF_EXPORT +CFDateFormatterRef CFDateFormatterCreate(CFAllocatorRef allocator, CFLocaleRef locale, CFDateFormatterStyle dateStyle, CFDateFormatterStyle timeStyle); + // Returns a CFDateFormatter, localized to the given locale, which + // will format dates to the given date and time styles. + +CF_EXPORT +CFLocaleRef CFDateFormatterGetLocale(CFDateFormatterRef formatter); + +CF_EXPORT +CFDateFormatterStyle CFDateFormatterGetDateStyle(CFDateFormatterRef formatter); + +CF_EXPORT +CFDateFormatterStyle CFDateFormatterGetTimeStyle(CFDateFormatterRef formatter); + // Get the properties with which the date formatter was created. + +CF_EXPORT +CFStringRef CFDateFormatterGetFormat(CFDateFormatterRef formatter); + +CF_EXPORT +void CFDateFormatterSetFormat(CFDateFormatterRef formatter, CFStringRef formatString); + // Set the format description string of the date formatter. This + // overrides the style settings. The format of the format string + // is as defined by the ICU library. The date formatter starts with a + // default format string defined by the style arguments with + // which it was created. + + +CF_EXPORT +CFStringRef CFDateFormatterCreateStringWithDate(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFDateRef date); + +CF_EXPORT +CFStringRef CFDateFormatterCreateStringWithAbsoluteTime(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFAbsoluteTime at); + // Create a string representation of the given date or CFAbsoluteTime + // using the current state of the date formatter. + + +CF_EXPORT +CFDateRef CFDateFormatterCreateDateFromString(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFStringRef string, CFRange *rangep); + +CF_EXPORT +Boolean CFDateFormatterGetAbsoluteTimeFromString(CFDateFormatterRef formatter, CFStringRef string, CFRange *rangep, CFAbsoluteTime *atp); + // Parse a string representation of a date using the current state + // of the date formatter. The range parameter specifies the range + // of the string in which the parsing should occur in input, and on + // output indicates the extent that was used; this parameter can + // be NULL, in which case the whole string may be used. The + // return value indicates whether some date was computed and + // (if atp is not NULL) stored at the location specified by atp. + + +CF_EXPORT +void CFDateFormatterSetProperty(CFDateFormatterRef formatter, CFStringRef key, CFTypeRef value); + +CF_EXPORT +CFTypeRef CFDateFormatterCopyProperty(CFDateFormatterRef formatter, CFStringRef key); + // Set and get various properties of the date formatter, the set of + // which may be expanded in the future. + +CF_EXPORT const CFStringRef kCFDateFormatterIsLenient; // CFBoolean +CF_EXPORT const CFStringRef kCFDateFormatterTimeZone; // CFTimeZone +CF_EXPORT const CFStringRef kCFDateFormatterCalendarName; // CFString +CF_EXPORT const CFStringRef kCFDateFormatterDefaultFormat; // CFString +CF_EXPORT const CFStringRef kCFDateFormatterTwoDigitStartDate; // CFDate +CF_EXPORT const CFStringRef kCFDateFormatterDefaultDate; // CFDate +CF_EXPORT const CFStringRef kCFDateFormatterCalendar; // CFCalendar +CF_EXPORT const CFStringRef kCFDateFormatterEraSymbols; // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterMonthSymbols; // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterShortMonthSymbols; // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterWeekdaySymbols; // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterShortWeekdaySymbols; // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterAMSymbol; // CFString +CF_EXPORT const CFStringRef kCFDateFormatterPMSymbol; // CFString +CF_EXPORT const CFStringRef kCFDateFormatterLongEraSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterVeryShortMonthSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterStandaloneMonthSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneMonthSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterVeryShortStandaloneMonthSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterVeryShortWeekdaySymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterStandaloneWeekdaySymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneWeekdaySymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterVeryShortStandaloneWeekdaySymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterQuarterSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterShortQuarterSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterStandaloneQuarterSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneQuarterSymbols CF_AVAILABLE(10_5, 2_0); // CFArray of CFString +CF_EXPORT const CFStringRef kCFDateFormatterGregorianStartDate CF_AVAILABLE(10_5, 2_0); // CFDate +CF_EXPORT const CFStringRef kCFDateFormatterDoesRelativeDateFormattingKey CF_AVAILABLE(10_6, 4_0); // CFBoolean + +// See CFLocale.h for these calendar constants: +// const CFStringRef kCFGregorianCalendar; +// const CFStringRef kCFBuddhistCalendar; +// const CFStringRef kCFJapaneseCalendar; +// const CFStringRef kCFIslamicCalendar; +// const CFStringRef kCFIslamicCivilCalendar; +// const CFStringRef kCFHebrewCalendar; +// const CFStringRef kCFChineseCalendar; +// const CFStringRef kCFRepublicOfChinaCalendar; +// const CFStringRef kCFPersianCalendar; +// const CFStringRef kCFIndianCalendar; +// const CFStringRef kCFISO8601Calendar; + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFDATEFORMATTER__ */ + diff --git a/include/CoreFoundation/CFDictionary.h b/include/CoreFoundation/CFDictionary.h new file mode 100644 index 0000000..b5c6194 --- /dev/null +++ b/include/CoreFoundation/CFDictionary.h @@ -0,0 +1,692 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFDictionary.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +/*! + @header CFDictionary + CFDictionary implements a container which pairs pointer-sized keys + with pointer-sized values. Values are accessed via arbitrary + user-defined keys. A CFDictionary differs from a CFArray in that + the key used to access a particular value in the dictionary remains + the same as values are added to or removed from the dictionary, + unless a value associated with its particular key is replaced or + removed. In a CFArray, the key (or index) used to retrieve a + particular value can change over time as values are added to or + deleted from the array. Also unlike an array, there is no ordering + among values in a dictionary. To enable later retrieval of a value, + the key of the key-value pair should be constant (or treated as + constant); if the key changes after being used to put a value in + the dictionary, the value may not be retrievable. The keys of a + dictionary form a set; that is, no two keys which are equal to + one another are present in the dictionary at any time. + + Dictionaries come in two flavors, immutable, which cannot have + values added to them or removed from them after the dictionary is + created, and mutable, to which you can add values or from which + remove values. Mutable dictionaries can have an unlimited number + of values (or rather, limited only by constraints external to + CFDictionary, like the amount of available memory). + + As with all CoreFoundation collection types, dictionaries maintain + hard references on the values you put in them, but the retaining and + releasing functions are user-defined callbacks that can actually do + whatever the user wants (for example, nothing). + + Although a particular implementation of CFDictionary may not use + hashing and a hash table for storage of the values, the keys have + a hash-code generating function defined for them, and a function + to test for equality of two keys. These two functions together + must maintain the invariant that if equal(X, Y), then hash(X) == + hash(Y). Note that the converse will not generally be true (but + the contrapositive, if hash(X) != hash(Y), then !equal(X, Y), + will be as required by Boolean logic). If the hash() and equal() + key callbacks are NULL, the key is used as a pointer-sized integer, + and pointer equality is used. Care should be taken to provide a + hash() callback which will compute sufficiently dispersed hash + codes for the key set for best performance. + + Computational Complexity + The access time for a value in the dictionary is guaranteed to be at + worst O(N) for any implementation, current and future, but will + often be O(1) (constant time). Insertion or deletion operations + will typically be constant time as well, but are O(N*N) in the + worst case in some implementations. Access of values through a key + is faster than accessing values directly (if there are any such + operations). Dictionaries will tend to use significantly more memory + than a array with the same number of values. +*/ + +#if !defined(__COREFOUNDATION_CFDICTIONARY__) +#define __COREFOUNDATION_CFDICTIONARY__ 1 + +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +/*! + @typedef CFDictionaryKeyCallBacks + Structure containing the callbacks for keys of a CFDictionary. + @field version The version number of the structure type being passed + in as a parameter to the CFDictionary creation functions. + This structure is version 0. + @field retain The callback used to add a retain for the dictionary + on keys as they are used to put values into the dictionary. + This callback returns the value to use as the key in the + dictionary, which is usually the value parameter passed to + this callback, but may be a different value if a different + value should be used as the key. The dictionary's allocator + is passed as the first argument. + @field release The callback used to remove a retain previously added + for the dictionary from keys as their values are removed from + the dictionary. The dictionary's allocator is passed as the + first argument. + @field copyDescription The callback used to create a descriptive + string representation of each key in the dictionary. This + is used by the CFCopyDescription() function. + @field equal The callback used to compare keys in the dictionary for + equality. + @field hash The callback used to compute a hash code for keys as they + are used to access, add, or remove values in the dictionary. +*/ +typedef const void * (*CFDictionaryRetainCallBack)(CFAllocatorRef allocator, const void *value); +typedef void (*CFDictionaryReleaseCallBack)(CFAllocatorRef allocator, const void *value); +typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack)(const void *value); +typedef Boolean (*CFDictionaryEqualCallBack)(const void *value1, const void *value2); +typedef CFHashCode (*CFDictionaryHashCallBack)(const void *value); +typedef struct { + CFIndex version; + CFDictionaryRetainCallBack retain; + CFDictionaryReleaseCallBack release; + CFDictionaryCopyDescriptionCallBack copyDescription; + CFDictionaryEqualCallBack equal; + CFDictionaryHashCallBack hash; +} CFDictionaryKeyCallBacks; + +/*! + @constant kCFTypeDictionaryKeyCallBacks + Predefined CFDictionaryKeyCallBacks structure containing a + set of callbacks appropriate for use when the keys of a + CFDictionary are all CFTypes. +*/ +CF_EXPORT +const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; + +/*! + @constant kCFCopyStringDictionaryKeyCallBacks + Predefined CFDictionaryKeyCallBacks structure containing a + set of callbacks appropriate for use when the keys of a + CFDictionary are all CFStrings, which may be mutable and + need to be copied in order to serve as constant keys for + the values in the dictionary. +*/ +CF_EXPORT +const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks; + +/*! + @typedef CFDictionaryValueCallBacks + Structure containing the callbacks for values of a CFDictionary. + @field version The version number of the structure type being passed + in as a parameter to the CFDictionary creation functions. + This structure is version 0. + @field retain The callback used to add a retain for the dictionary + on values as they are put into the dictionary. + This callback returns the value to use as the value in the + dictionary, which is usually the value parameter passed to + this callback, but may be a different value if a different + value should be added to the dictionary. The dictionary's + allocator is passed as the first argument. + @field release The callback used to remove a retain previously added + for the dictionary from values as they are removed from + the dictionary. The dictionary's allocator is passed as the + first argument. + @field copyDescription The callback used to create a descriptive + string representation of each value in the dictionary. This + is used by the CFCopyDescription() function. + @field equal The callback used to compare values in the dictionary for + equality in some operations. +*/ +typedef struct { + CFIndex version; + CFDictionaryRetainCallBack retain; + CFDictionaryReleaseCallBack release; + CFDictionaryCopyDescriptionCallBack copyDescription; + CFDictionaryEqualCallBack equal; +} CFDictionaryValueCallBacks; + +/*! + @constant kCFTypeDictionaryValueCallBacks + Predefined CFDictionaryValueCallBacks structure containing a set + of callbacks appropriate for use when the values in a CFDictionary + are all CFTypes. +*/ +CF_EXPORT +const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; + +/*! + @typedef CFDictionaryApplierFunction + Type of the callback function used by the apply functions of + CFDictionarys. + @param key The current key for the value. + @param value The current value from the dictionary. + @param context The user-defined context parameter given to the apply + function. +*/ +typedef void (*CFDictionaryApplierFunction)(const void *key, const void *value, void *context); + +/*! + @typedef CFDictionaryRef + This is the type of a reference to immutable CFDictionarys. +*/ +typedef const struct CF_BRIDGED_TYPE(NSDictionary) __CFDictionary * CFDictionaryRef; + +/*! + @typedef CFMutableDictionaryRef + This is the type of a reference to mutable CFDictionarys. +*/ +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableDictionary) __CFDictionary * CFMutableDictionaryRef; + +/*! + @function CFDictionaryGetTypeID + Returns the type identifier of all CFDictionary instances. +*/ +CF_EXPORT +CFTypeID CFDictionaryGetTypeID(void); + +/*! + @function CFDictionaryCreate + Creates a new immutable dictionary with the given values. + @param allocator The CFAllocator which should be used to allocate + memory for the dictionary and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param keys A C array of the pointer-sized keys to be used for + the parallel C array of values to be put into the dictionary. + This parameter may be NULL if the numValues parameter is 0. + This C array is not changed or freed by this function. If + this parameter is not a valid pointer to a C array of at + least numValues pointers, the behavior is undefined. + @param values A C array of the pointer-sized values to be in the + dictionary. This parameter may be NULL if the numValues + parameter is 0. This C array is not changed or freed by + this function. If this parameter is not a valid pointer to + a C array of at least numValues pointers, the behavior is + undefined. + @param numValues The number of values to copy from the keys and + values C arrays into the CFDictionary. This number will be + the count of the dictionary. If this parameter is + negative, or greater than the number of values actually + in the keys or values C arrays, the behavior is undefined. + @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure + initialized with the callbacks for the dictionary to use on + each key in the dictionary. The retain callback will be used + within this function, for example, to retain all of the new + keys from the keys C array. A copy of the contents of the + callbacks structure is made, so that a pointer to a structure + on the stack can be passed in, or can be reused for multiple + dictionary creations. If the version field of this + callbacks structure is not one of the defined ones for + CFDictionary, the behavior is undefined. The retain field may + be NULL, in which case the CFDictionary will do nothing to add + a retain to the keys of the contained values. The release field + may be NULL, in which case the CFDictionary will do nothing + to remove the dictionary's retain (if any) on the keys when the + dictionary is destroyed or a key-value pair is removed. If the + copyDescription field is NULL, the dictionary will create a + simple description for a key. If the equal field is NULL, the + dictionary will use pointer equality to test for equality of + keys. If the hash field is NULL, a key will be converted from + a pointer to an integer to compute the hash code. This callbacks + parameter itself may be NULL, which is treated as if a valid + structure of version 0 with all fields NULL had been passed in. + Otherwise, if any of the fields are not valid pointers to + functions of the correct type, or this parameter is not a + valid pointer to a CFDictionaryKeyCallBacks callbacks structure, + the behavior is undefined. If any of the keys put into the + dictionary is not one understood by one of the callback functions + the behavior when that callback function is used is undefined. + @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure + initialized with the callbacks for the dictionary to use on + each value in the dictionary. The retain callback will be used + within this function, for example, to retain all of the new + values from the values C array. A copy of the contents of the + callbacks structure is made, so that a pointer to a structure + on the stack can be passed in, or can be reused for multiple + dictionary creations. If the version field of this callbacks + structure is not one of the defined ones for CFDictionary, the + behavior is undefined. The retain field may be NULL, in which + case the CFDictionary will do nothing to add a retain to values + as they are put into the dictionary. The release field may be + NULL, in which case the CFDictionary will do nothing to remove + the dictionary's retain (if any) on the values when the + dictionary is destroyed or a key-value pair is removed. If the + copyDescription field is NULL, the dictionary will create a + simple description for a value. If the equal field is NULL, the + dictionary will use pointer equality to test for equality of + values. This callbacks parameter itself may be NULL, which is + treated as if a valid structure of version 0 with all fields + NULL had been passed in. Otherwise, + if any of the fields are not valid pointers to functions + of the correct type, or this parameter is not a valid + pointer to a CFDictionaryValueCallBacks callbacks structure, + the behavior is undefined. If any of the values put into the + dictionary is not one understood by one of the callback functions + the behavior when that callback function is used is undefined. + @result A reference to the new immutable CFDictionary. +*/ +CF_EXPORT +CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks); + +/*! + @function CFDictionaryCreateCopy + Creates a new immutable dictionary with the key-value pairs from + the given dictionary. + @param allocator The CFAllocator which should be used to allocate + memory for the dictionary and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param theDict The dictionary which is to be copied. The keys and values + from the dictionary are copied as pointers into the new + dictionary (that is, the values themselves are copied, not + that which the values point to, if anything). However, the + keys and values are also retained by the new dictionary using + the retain function of the original dictionary. + The count of the new dictionary will be the same as the + given dictionary. The new dictionary uses the same callbacks + as the dictionary to be copied. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @result A reference to the new immutable CFDictionary. +*/ +CF_EXPORT +CFDictionaryRef CFDictionaryCreateCopy(CFAllocatorRef allocator, CFDictionaryRef theDict); + +/*! + @function CFDictionaryCreateMutable + Creates a new mutable dictionary. + @param allocator The CFAllocator which should be used to allocate + memory for the dictionary and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param capacity A hint about the number of values that will be held + by the CFDictionary. Pass 0 for no hint. The implementation may + ignore this hint, or may use it to optimize various + operations. A dictionary's actual capacity is only limited by + address space and available memory constraints). If this + parameter is negative, the behavior is undefined. + @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure + initialized with the callbacks for the dictionary to use on + each key in the dictionary. A copy of the contents of the + callbacks structure is made, so that a pointer to a structure + on the stack can be passed in, or can be reused for multiple + dictionary creations. If the version field of this + callbacks structure is not one of the defined ones for + CFDictionary, the behavior is undefined. The retain field may + be NULL, in which case the CFDictionary will do nothing to add + a retain to the keys of the contained values. The release field + may be NULL, in which case the CFDictionary will do nothing + to remove the dictionary's retain (if any) on the keys when the + dictionary is destroyed or a key-value pair is removed. If the + copyDescription field is NULL, the dictionary will create a + simple description for a key. If the equal field is NULL, the + dictionary will use pointer equality to test for equality of + keys. If the hash field is NULL, a key will be converted from + a pointer to an integer to compute the hash code. This callbacks + parameter itself may be NULL, which is treated as if a valid + structure of version 0 with all fields NULL had been passed in. + Otherwise, if any of the fields are not valid pointers to + functions of the correct type, or this parameter is not a + valid pointer to a CFDictionaryKeyCallBacks callbacks structure, + the behavior is undefined. If any of the keys put into the + dictionary is not one understood by one of the callback functions + the behavior when that callback function is used is undefined. + @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure + initialized with the callbacks for the dictionary to use on + each value in the dictionary. The retain callback will be used + within this function, for example, to retain all of the new + values from the values C array. A copy of the contents of the + callbacks structure is made, so that a pointer to a structure + on the stack can be passed in, or can be reused for multiple + dictionary creations. If the version field of this callbacks + structure is not one of the defined ones for CFDictionary, the + behavior is undefined. The retain field may be NULL, in which + case the CFDictionary will do nothing to add a retain to values + as they are put into the dictionary. The release field may be + NULL, in which case the CFDictionary will do nothing to remove + the dictionary's retain (if any) on the values when the + dictionary is destroyed or a key-value pair is removed. If the + copyDescription field is NULL, the dictionary will create a + simple description for a value. If the equal field is NULL, the + dictionary will use pointer equality to test for equality of + values. This callbacks parameter itself may be NULL, which is + treated as if a valid structure of version 0 with all fields + NULL had been passed in. Otherwise, + if any of the fields are not valid pointers to functions + of the correct type, or this parameter is not a valid + pointer to a CFDictionaryValueCallBacks callbacks structure, + the behavior is undefined. If any of the values put into the + dictionary is not one understood by one of the callback functions + the behavior when that callback function is used is undefined. + @result A reference to the new mutable CFDictionary. +*/ +CF_EXPORT +CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks); + +/*! + @function CFDictionaryCreateMutableCopy + Creates a new mutable dictionary with the key-value pairs from + the given dictionary. + @param allocator The CFAllocator which should be used to allocate + memory for the dictionary and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param capacity A hint about the number of values that will be held + by the CFDictionary. Pass 0 for no hint. The implementation may + ignore this hint, or may use it to optimize various + operations. A dictionary's actual capacity is only limited by + address space and available memory constraints). + This parameter must be greater than or equal + to the count of the dictionary which is to be copied, or the + behavior is undefined. If this parameter is negative, the + behavior is undefined. + @param theDict The dictionary which is to be copied. The keys and values + from the dictionary are copied as pointers into the new + dictionary (that is, the values themselves are copied, not + that which the values point to, if anything). However, the + keys and values are also retained by the new dictionary using + the retain function of the original dictionary. + The count of the new dictionary will be the same as the + given dictionary. The new dictionary uses the same callbacks + as the dictionary to be copied. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @result A reference to the new mutable CFDictionary. +*/ +CF_EXPORT +CFMutableDictionaryRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDictionaryRef theDict); + +/*! + @function CFDictionaryGetCount + Returns the number of values currently in the dictionary. + @param theDict The dictionary to be queried. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @result The number of values in the dictionary. +*/ +CF_EXPORT +CFIndex CFDictionaryGetCount(CFDictionaryRef theDict); + +/*! + @function CFDictionaryGetCountOfKey + Counts the number of times the given key occurs in the dictionary. + @param theDict The dictionary to be searched. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @param key The key for which to find matches in the dictionary. The + hash() and equal() key callbacks provided when the dictionary + was created are used to compare. If the hash() key callback + was NULL, the key is treated as a pointer and converted to + an integer. If the equal() key callback was NULL, pointer + equality (in C, ==) is used. If key, or any of the keys in + the dictionary, are not understood by the equal() callback, + the behavior is undefined. + @result Returns 1 if a matching key is used by the dictionary, + 0 otherwise. +*/ +CF_EXPORT +CFIndex CFDictionaryGetCountOfKey(CFDictionaryRef theDict, const void *key); + +/*! + @function CFDictionaryGetCountOfValue + Counts the number of times the given value occurs in the dictionary. + @param theDict The dictionary to be searched. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @param value The value for which to find matches in the dictionary. The + equal() callback provided when the dictionary was created is + used to compare. If the equal() value callback was NULL, pointer + equality (in C, ==) is used. If value, or any of the values in + the dictionary, are not understood by the equal() callback, + the behavior is undefined. + @result The number of times the given value occurs in the dictionary. +*/ +CF_EXPORT +CFIndex CFDictionaryGetCountOfValue(CFDictionaryRef theDict, const void *value); + +/*! + @function CFDictionaryContainsKey + Reports whether or not the key is in the dictionary. + @param theDict The dictionary to be searched. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @param key The key for which to find matches in the dictionary. The + hash() and equal() key callbacks provided when the dictionary + was created are used to compare. If the hash() key callback + was NULL, the key is treated as a pointer and converted to + an integer. If the equal() key callback was NULL, pointer + equality (in C, ==) is used. If key, or any of the keys in + the dictionary, are not understood by the equal() callback, + the behavior is undefined. + @result true, if the key is in the dictionary, otherwise false. +*/ +CF_EXPORT +Boolean CFDictionaryContainsKey(CFDictionaryRef theDict, const void *key); + +/*! + @function CFDictionaryContainsValue + Reports whether or not the value is in the dictionary. + @param theDict The dictionary to be searched. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @param value The value for which to find matches in the dictionary. The + equal() callback provided when the dictionary was created is + used to compare. If the equal() callback was NULL, pointer + equality (in C, ==) is used. If value, or any of the values + in the dictionary, are not understood by the equal() callback, + the behavior is undefined. + @result true, if the value is in the dictionary, otherwise false. +*/ +CF_EXPORT +Boolean CFDictionaryContainsValue(CFDictionaryRef theDict, const void *value); + +/*! + @function CFDictionaryGetValue + Retrieves the value associated with the given key. + @param theDict The dictionary to be queried. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @param key The key for which to find a match in the dictionary. The + hash() and equal() key callbacks provided when the dictionary + was created are used to compare. If the hash() key callback + was NULL, the key is treated as a pointer and converted to + an integer. If the equal() key callback was NULL, pointer + equality (in C, ==) is used. If key, or any of the keys in + the dictionary, are not understood by the equal() callback, + the behavior is undefined. + @result The value with the given key in the dictionary, or NULL if + no key-value pair with a matching key exists. Since NULL + can be a valid value in some dictionaries, the function + CFDictionaryGetValueIfPresent() must be used to distinguish + NULL-no-found from NULL-is-the-value. +*/ +CF_EXPORT +const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key); + +/*! + @function CFDictionaryGetValueIfPresent + Retrieves the value associated with the given key. + @param theDict The dictionary to be queried. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @param key The key for which to find a match in the dictionary. The + hash() and equal() key callbacks provided when the dictionary + was created are used to compare. If the hash() key callback + was NULL, the key is treated as a pointer and converted to + an integer. If the equal() key callback was NULL, pointer + equality (in C, ==) is used. If key, or any of the keys in + the dictionary, are not understood by the equal() callback, + the behavior is undefined. + @param value A pointer to memory which should be filled with the + pointer-sized value if a matching key is found. If no key + match is found, the contents of the storage pointed to by + this parameter are undefined. This parameter may be NULL, + in which case the value from the dictionary is not returned + (but the return value of this function still indicates + whether or not the key-value pair was present). + @result true, if a matching key was found, false otherwise. +*/ +CF_EXPORT +Boolean CFDictionaryGetValueIfPresent(CFDictionaryRef theDict, const void *key, const void **value); + +/*! + @function CFDictionaryGetKeysAndValues + Fills the two buffers with the keys and values from the dictionary. + @param theDict The dictionary to be queried. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @param keys A C array of pointer-sized values to be filled with keys + from the dictionary. The keys and values C arrays are parallel + to each other (that is, the items at the same indices form a + key-value pair from the dictionary). This parameter may be NULL + if the keys are not desired. If this parameter is not a valid + pointer to a C array of at least CFDictionaryGetCount() pointers, + or NULL, the behavior is undefined. + @param values A C array of pointer-sized values to be filled with values + from the dictionary. The keys and values C arrays are parallel + to each other (that is, the items at the same indices form a + key-value pair from the dictionary). This parameter may be NULL + if the values are not desired. If this parameter is not a valid + pointer to a C array of at least CFDictionaryGetCount() pointers, + or NULL, the behavior is undefined. +*/ +CF_EXPORT +void CFDictionaryGetKeysAndValues(CFDictionaryRef theDict, const void **keys, const void **values); + +/*! + @function CFDictionaryApplyFunction + Calls a function once for each value in the dictionary. + @param theDict The dictionary to be queried. If this parameter is + not a valid CFDictionary, the behavior is undefined. + @param applier The callback function to call once for each value in + the dictionary. If this parameter is not a + pointer to a function of the correct prototype, the behavior + is undefined. If there are keys or values which the + applier function does not expect or cannot properly apply + to, the behavior is undefined. + @param context A pointer-sized user-defined value, which is passed + as the third parameter to the applier function, but is + otherwise unused by this function. If the context is not + what is expected by the applier function, the behavior is + undefined. +*/ +CF_EXPORT +void CFDictionaryApplyFunction(CFDictionaryRef theDict, CFDictionaryApplierFunction applier, void *context); + +/*! + @function CFDictionaryAddValue + Adds the key-value pair to the dictionary if no such key already exists. + @param theDict The dictionary to which the value is to be added. If this + parameter is not a valid mutable CFDictionary, the behavior is + undefined. + @param key The key of the value to add to the dictionary. The key is + retained by the dictionary using the retain callback provided + when the dictionary was created. If the key is not of the sort + expected by the retain callback, the behavior is undefined. If + a key which matches this key is already present in the dictionary, + this function does nothing ("add if absent"). + @param value The value to add to the dictionary. The value is retained + by the dictionary using the retain callback provided when the + dictionary was created. If the value is not of the sort expected + by the retain callback, the behavior is undefined. +*/ +CF_EXPORT +void CFDictionaryAddValue(CFMutableDictionaryRef theDict, const void *key, const void *value); + +/*! + @function CFDictionarySetValue + Sets the value of the key in the dictionary. + @param theDict The dictionary to which the value is to be set. If this + parameter is not a valid mutable CFDictionary, the behavior is + undefined. + @param key The key of the value to set into the dictionary. If a key + which matches this key is already present in the dictionary, only + the value is changed ("add if absent, replace if present"). If + no key matches the given key, the key-value pair is added to the + dictionary. If added, the key is retained by the dictionary, + using the retain callback provided + when the dictionary was created. If the key is not of the sort + expected by the key retain callback, the behavior is undefined. + @param value The value to add to or replace into the dictionary. The value + is retained by the dictionary using the retain callback provided + when the dictionary was created, and the previous value if any is + released. If the value is not of the sort expected by the + retain or release callbacks, the behavior is undefined. +*/ +CF_EXPORT +void CFDictionarySetValue(CFMutableDictionaryRef theDict, const void *key, const void *value); + +/*! + @function CFDictionaryReplaceValue + Replaces the value of the key in the dictionary. + @param theDict The dictionary to which the value is to be replaced. If this + parameter is not a valid mutable CFDictionary, the behavior is + undefined. + @param key The key of the value to replace in the dictionary. If a key + which matches this key is present in the dictionary, the value + is changed to the given value, otherwise this function does + nothing ("replace if present"). + @param value The value to replace into the dictionary. The value + is retained by the dictionary using the retain callback provided + when the dictionary was created, and the previous value is + released. If the value is not of the sort expected by the + retain or release callbacks, the behavior is undefined. +*/ +CF_EXPORT +void CFDictionaryReplaceValue(CFMutableDictionaryRef theDict, const void *key, const void *value); + +/*! + @function CFDictionaryRemoveValue + Removes the value of the key from the dictionary. + @param theDict The dictionary from which the value is to be removed. If this + parameter is not a valid mutable CFDictionary, the behavior is + undefined. + @param key The key of the value to remove from the dictionary. If a key + which matches this key is present in the dictionary, the key-value + pair is removed from the dictionary, otherwise this function does + nothing ("remove if present"). +*/ +CF_EXPORT +void CFDictionaryRemoveValue(CFMutableDictionaryRef theDict, const void *key); + +/*! + @function CFDictionaryRemoveAllValues + Removes all the values from the dictionary, making it empty. + @param theDict The dictionary from which all of the values are to be + removed. If this parameter is not a valid mutable + CFDictionary, the behavior is undefined. +*/ +CF_EXPORT +void CFDictionaryRemoveAllValues(CFMutableDictionaryRef theDict); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFDICTIONARY__ */ + diff --git a/include/CoreFoundation/CFError.h b/include/CoreFoundation/CFError.h new file mode 100644 index 0000000..0b5ff49 --- /dev/null +++ b/include/CoreFoundation/CFError.h @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFError.h + Copyright (c) 2006-2014, Apple Inc. All rights reserved. +*/ + +/*! + @header CFError + @discussion + CFErrors are used to encompass information about errors. At minimum, errors are identified by their domain (a string) and an error code within that domain. In addition a "userInfo" dictionary supplied at creation time enables providing additional info that might be useful for the interpretation and reporting of the error. This dictionary can even contain an "underlying" error, which is wrapped as an error bubbles up through various layers. + + CFErrors have the ability to provide human-readable descriptions for the errors; in fact, they are designed to provide localizable, end-user presentable errors that can appear in the UI. CFError has a number of predefined userInfo keys to enable developers to supply the info. + + Usage recommendation for CFErrors is to return them as by-ref parameters in functions. This enables the caller to pass NULL in when they don't actually want information about the error. The presence of an error should be reported by other means, for instance a NULL or false return value from the function call proper: + + CFError *error; + if (!ReadFromFile(fd, &error)) { + ... process error ... + CFRelease(error); // If an error occurs, the returned CFError must be released. + } + + It is the responsibility of anyone returning CFErrors this way to: + - Not touch the error argument if no error occurs + - Create and assign the error for return only if the error argument is non-NULL + + In addition, it's recommended that CFErrors be used in error situations only (not status), and where there are multiple possible errors to distinguish between. For instance there is no plan to add CFErrors to existing APIs in CF which currently don't return errors; in many cases, there is one possible reason for failure, and a false or NULL return is enough to indicate it. + + CFError is toll-free bridged to NSError in Foundation. NSError in Foundation has some additional guidelines which makes it easy to automatically report errors to users and even try to recover from them. See http://developer.apple.com/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorHandling/chapter_1_section_1.html for more info on NSError programming guidelines. +*/ + +#if !defined(__COREFOUNDATION_CFERROR__) +#define __COREFOUNDATION_CFERROR__ 1 + +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +/*! + @typedef CFErrorRef + This is the type of a reference to CFErrors. CFErrorRef is toll-free bridged with NSError. +*/ +typedef struct CF_BRIDGED_TYPE(NSError) __CFError * CFErrorRef; + +/*! + @function CFErrorGetTypeID + Returns the type identifier of all CFError instances. +*/ +CF_EXPORT +CFTypeID CFErrorGetTypeID(void) CF_AVAILABLE(10_5, 2_0); + + +// Predefined domains; value of "code" will correspond to preexisting values in these domains. +CF_EXPORT const CFStringRef kCFErrorDomainPOSIX CF_AVAILABLE(10_5, 2_0); +CF_EXPORT const CFStringRef kCFErrorDomainOSStatus CF_AVAILABLE(10_5, 2_0); +CF_EXPORT const CFStringRef kCFErrorDomainMach CF_AVAILABLE(10_5, 2_0); +CF_EXPORT const CFStringRef kCFErrorDomainCocoa CF_AVAILABLE(10_5, 2_0); + +// Keys in userInfo for localizable, end-user presentable error messages. At minimum provide one of first two; ideally provide all three. +CF_EXPORT const CFStringRef kCFErrorLocalizedDescriptionKey CF_AVAILABLE(10_5, 2_0); // Key to identify the end user-presentable description in userInfo. +CF_EXPORT const CFStringRef kCFErrorLocalizedFailureReasonKey CF_AVAILABLE(10_5, 2_0); // Key to identify the end user-presentable failure reason in userInfo. +CF_EXPORT const CFStringRef kCFErrorLocalizedRecoverySuggestionKey CF_AVAILABLE(10_5, 2_0); // Key to identify the end user-presentable recovery suggestion in userInfo. + +// If you do not have localizable error strings, you can provide a value for this key instead. +CF_EXPORT const CFStringRef kCFErrorDescriptionKey CF_AVAILABLE(10_5, 2_0); // Key to identify the description in the userInfo dictionary. Should be a complete sentence if possible. Should not contain domain name or error code. + +// Other keys in userInfo. +CF_EXPORT const CFStringRef kCFErrorUnderlyingErrorKey CF_AVAILABLE(10_5, 2_0); // Key to identify the underlying error in userInfo. +CF_EXPORT const CFStringRef kCFErrorURLKey CF_AVAILABLE(10_7, 5_0); // Key to identify associated URL in userInfo. Typically one of this or kCFErrorFilePathKey is provided. +CF_EXPORT const CFStringRef kCFErrorFilePathKey CF_AVAILABLE(10_7, 5_0); // Key to identify associated file path in userInfo. Typically one of this or kCFErrorURLKey is provided. + + +/*! + @function CFErrorCreate + @abstract Creates a new CFError. + @param allocator The CFAllocator which should be used to allocate memory for the error. This parameter may be NULL in which case the + current default CFAllocator is used. If this reference is not a valid CFAllocator, the behavior is undefined. + @param domain A CFString identifying the error domain. If this reference is NULL or is otherwise not a valid CFString, the behavior is undefined. + @param code A CFIndex identifying the error code. The code is interpreted within the context of the error domain. + @param userInfo A CFDictionary created with kCFCopyStringDictionaryKeyCallBacks and kCFTypeDictionaryValueCallBacks. It will be copied with CFDictionaryCreateCopy(). + If no userInfo dictionary is desired, NULL may be passed in as a convenience, in which case an empty userInfo dictionary will be assigned. + @result A reference to the new CFError. +*/ +CF_EXPORT +CFErrorRef CFErrorCreate(CFAllocatorRef allocator, CFStringRef domain, CFIndex code, CFDictionaryRef userInfo) CF_AVAILABLE(10_5, 2_0); + +/*! + @function CFErrorCreateWithUserInfoKeysAndValues + @abstract Creates a new CFError without having to create an intermediate userInfo dictionary. + @param allocator The CFAllocator which should be used to allocate memory for the error. This parameter may be NULL in which case the + current default CFAllocator is used. If this reference is not a valid CFAllocator, the behavior is undefined. + @param domain A CFString identifying the error domain. If this reference is NULL or is otherwise not a valid CFString, the behavior is undefined. + @param code A CFIndex identifying the error code. The code is interpreted within the context of the error domain. + @param userInfoKeys An array of numUserInfoValues CFStrings used as keys in creating the userInfo dictionary. NULL is valid only if numUserInfoValues is 0. + @param userInfoValues An array of numUserInfoValues CF types used as values in creating the userInfo dictionary. NULL is valid only if numUserInfoValues is 0. + @param numUserInfoValues CFIndex representing the number of keys and values in the userInfoKeys and userInfoValues arrays. + @result A reference to the new CFError. numUserInfoValues CF types are gathered from each of userInfoKeys and userInfoValues to create the userInfo dictionary. +*/ +CF_EXPORT +CFErrorRef CFErrorCreateWithUserInfoKeysAndValues(CFAllocatorRef allocator, CFStringRef domain, CFIndex code, const void *const *userInfoKeys, const void *const *userInfoValues, CFIndex numUserInfoValues) CF_AVAILABLE(10_5, 2_0); + +/*! + @function CFErrorGetDomain + @abstract Returns the error domain the CFError was created with. + @param err The CFError whose error domain is to be returned. If this reference is not a valid CFError, the behavior is undefined. + @result The error domain of the CFError. Since this is a "Get" function, the caller shouldn't CFRelease the return value. +*/ +CF_EXPORT +CFStringRef CFErrorGetDomain(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); + +/*! + @function CFErrorGetCode + @abstract Returns the error code the CFError was created with. + @param err The CFError whose error code is to be returned. If this reference is not a valid CFError, the behavior is undefined. + @result The error code of the CFError (not an error return for the current call). +*/ +CF_EXPORT +CFIndex CFErrorGetCode(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); + +/*! + @function CFErrorCopyUserInfo + @abstract Returns CFError userInfo dictionary. + @discussion Returns a dictionary containing the same keys and values as in the userInfo dictionary the CFError was created with. Returns an empty dictionary if NULL was supplied to CFErrorCreate(). + @param err The CFError whose error user info is to be returned. If this reference is not a valid CFError, the behavior is undefined. + @result The user info of the CFError. +*/ +CF_EXPORT +CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); + +/*! + @function CFErrorCopyDescription + @abstract Returns a human-presentable description for the error. CFError creators should strive to make sure the return value is human-presentable and localized by providing a value for kCFErrorLocalizedDescriptionKey at the time of CFError creation. + @discussion This is a complete sentence or two which says what failed and why it failed. Rules for computing the return value: + - Look for kCFErrorLocalizedDescriptionKey in the user info and if not NULL, returns that as-is. + - Otherwise, if there is a kCFErrorLocalizedFailureReasonKey in the user info, generate an error from that. Something like: "Operation code not be completed. " + kCFErrorLocalizedFailureReasonKey + - Otherwise, generate a semi-user presentable string from kCFErrorDescriptionKey, the domain, and code. Something like: "Operation could not be completed. Error domain/code occurred. " or "Operation could not be completed. " + kCFErrorDescriptionKey + " (Error domain/code)" + Toll-free bridged NSError instances might provide additional behaviors for manufacturing a description string. Do not count on the exact contents or format of the returned string, it might change. + @param err The CFError whose description is to be returned. If this reference is not a valid CFError, the behavior is undefined. + @result A CFString with human-presentable description of the CFError. Never NULL. +*/ +CF_EXPORT +CFStringRef CFErrorCopyDescription(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); + +/*! + @function CFErrorCopyFailureReason + @abstract Returns a human-presentable failure reason for the error. May return NULL. CFError creators should strive to make sure the return value is human-presentable and localized by providing a value for kCFErrorLocalizedFailureReasonKey at the time of CFError creation. + @discussion This is a complete sentence which describes why the operation failed. In many cases this will be just the "because" part of the description (but as a complete sentence, which makes localization easier). By default this looks for kCFErrorLocalizedFailureReasonKey in the user info. Toll-free bridged NSError instances might provide additional behaviors for manufacturing this value. If no user-presentable string is available, returns NULL. + Example Description: "Could not save file 'Letter' in folder 'Documents' because the volume 'MyDisk' doesn't have enough space." + Corresponding FailureReason: "The volume 'MyDisk' doesn't have enough space." + @param err The CFError whose failure reason is to be returned. If this reference is not a valid CFError, the behavior is undefined. + @result A CFString with the localized, end-user presentable failure reason of the CFError, or NULL. +*/ +CF_EXPORT +CFStringRef CFErrorCopyFailureReason(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); + +/*! + @function CFErrorCopyRecoverySuggestion + @abstract Returns a human presentable recovery suggestion for the error. May return NULL. CFError creators should strive to make sure the return value is human-presentable and localized by providing a value for kCFErrorLocalizedRecoverySuggestionKey at the time of CFError creation. + @discussion This is the string that can be displayed as the "informative" (aka "secondary") message on an alert panel. By default this looks for kCFErrorLocalizedRecoverySuggestionKey in the user info. Toll-free bridged NSError instances might provide additional behaviors for manufacturing this value. If no user-presentable string is available, returns NULL. + Example Description: "Could not save file 'Letter' in folder 'Documents' because the volume 'MyDisk' doesn't have enough space." + Corresponding RecoverySuggestion: "Remove some files from the volume and try again." + @param err The CFError whose recovery suggestion is to be returned. If this reference is not a valid CFError, the behavior is undefined. + @result A CFString with the localized, end-user presentable recovery suggestion of the CFError, or NULL. +*/ +CF_EXPORT +CFStringRef CFErrorCopyRecoverySuggestion(CFErrorRef err) CF_AVAILABLE(10_5, 2_0); + + + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFERROR__ */ + diff --git a/include/CoreFoundation/CFError_Private.h b/include/CoreFoundation/CFError_Private.h new file mode 100644 index 0000000..e053bda --- /dev/null +++ b/include/CoreFoundation/CFError_Private.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFError_Private.h + Copyright (c) 2006-2014, Apple Inc. All rights reserved. + + This is Apple-internal SPI for CFError. +*/ + +#if !defined(__COREFOUNDATION_CFERRORPRIVATE__) +#define __COREFOUNDATION_CFERRORPRIVATE__ 1 + +#include + +CF_EXTERN_C_BEGIN + +/* 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. +*/ +typedef CFTypeRef (*CFErrorUserInfoKeyCallBack)(CFErrorRef err, CFStringRef key); +CF_EXPORT void CFErrorSetCallBackForDomain(CFStringRef domainName, CFErrorUserInfoKeyCallBack callBack) CF_AVAILABLE(10_5, 2_0); +CF_EXPORT CFErrorUserInfoKeyCallBack CFErrorGetCallBackForDomain(CFStringRef domainName) CF_AVAILABLE(10_5, 2_0); + + +/* 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. +*/ +CF_EXPORT const CFStringRef kCFErrorDebugDescriptionKey CF_AVAILABLE(10_5, 2_0); + + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFERRORPRIVATE__ */ + diff --git a/include/CoreFoundation/CFFileDescriptor.h b/include/CoreFoundation/CFFileDescriptor.h new file mode 100644 index 0000000..0e9b86c --- /dev/null +++ b/include/CoreFoundation/CFFileDescriptor.h @@ -0,0 +1,39 @@ +#if !defined(__COREFOUNDATION_CFFILEDESCRIPTOR__) +#define __COREFOUNDATION_CFFILEDESCRIPTOR__ 1 + +#include + +CF_EXTERN_C_BEGIN + +typedef int CFFileDescriptorNativeDescriptor; + +typedef struct __CFFileDescriptor * CFFileDescriptorRef; + +enum { + kCFFileDescriptorReadCallBack = 1UL << 0, + kCFFileDescriptorWriteCallBack = 1UL << 1 +}; + +typedef void (*CFFileDescriptorCallBack)(CFFileDescriptorRef f, CFOptionFlags callBackTypes, void *info); + +typedef struct { + CFIndex version; + void *info; + void *(*retain)(void *info); + void (*release)(void *info); + CFStringRef (*copyDescription)(void *info); +} CFFileDescriptorContext; + +CF_EXPORT CFTypeID CFFileDescriptorGetTypeID(void); +CF_EXPORT CFFileDescriptorRef CFFileDescriptorCreate(CFAllocatorRef allocator, CFFileDescriptorNativeDescriptor fd, Boolean closeOnInvalidate, CFFileDescriptorCallBack callout, const CFFileDescriptorContext *context); +CF_EXPORT CFFileDescriptorNativeDescriptor CFFileDescriptorGetNativeDescriptor(CFFileDescriptorRef f); +CF_EXPORT void CFFileDescriptorGetContext(CFFileDescriptorRef f, CFFileDescriptorContext *context); +CF_EXPORT void CFFileDescriptorEnableCallBacks(CFFileDescriptorRef f, CFOptionFlags callBackTypes); +CF_EXPORT void CFFileDescriptorDisableCallBacks(CFFileDescriptorRef f, CFOptionFlags callBackTypes); +CF_EXPORT void CFFileDescriptorInvalidate(CFFileDescriptorRef f); +CF_EXPORT Boolean CFFileDescriptorIsValid(CFFileDescriptorRef f); +CF_EXPORT CFRunLoopSourceRef CFFileDescriptorCreateRunLoopSource(CFAllocatorRef allocator, CFFileDescriptorRef f, CFIndex order); + +CF_EXTERN_C_END + +#endif diff --git a/include/CoreFoundation/CFFileSecurity.h b/include/CoreFoundation/CFFileSecurity.h new file mode 100644 index 0000000..f950640 --- /dev/null +++ b/include/CoreFoundation/CFFileSecurity.h @@ -0,0 +1,47 @@ +#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION + +#if !defined(__COREFOUNDATION_CFFILESECURITY__) +#define __COREFOUNDATION_CFFILESECURITY__ 1 + +#include +#include +#include +#include + +CF_EXTERN_C_BEGIN + +#define kCFFileSecurityRemoveACL(acl_t) _FILESEC_REMOVE_ACL + +enum { + kCFFileSecurityClearOwner = 1UL << 0, + kCFFileSecurityClearGroup = 1UL << 1, + kCFFileSecurityClearMode = 1UL << 2, + kCFFileSecurityClearOwnerUUID = 1UL << 3, + kCFFileSecurityClearGroupUUID = 1UL << 4, + kCFFileSecurityClearAccessControlList = 1UL << 5 +}; + +typedef struct __CFFileSecurity* CFFileSecurityRef; + +CF_EXPORT CFTypeID CFFileSecurityGetTypeID(void); +CF_EXPORT CFFileSecurityRef CFFileSecurityCreate(CFAllocatorRef allocator); +CF_EXPORT CFFileSecurityRef CFFileSecurityCreateCopy(CFAllocatorRef allocator, CFFileSecurityRef fileSec); +CF_EXPORT Boolean CFFileSecurityCopyOwnerUUID(CFFileSecurityRef fileSec, CFUUIDRef *ownerUUID); +CF_EXPORT Boolean CFFileSecuritySetOwnerUUID(CFFileSecurityRef fileSec, CFUUIDRef ownerUUID); +CF_EXPORT Boolean CFFileSecurityCopyGroupUUID(CFFileSecurityRef fileSec, CFUUIDRef *groupUUID); +CF_EXPORT Boolean CFFileSecuritySetGroupUUID(CFFileSecurityRef fileSec, CFUUIDRef groupUUID); +CF_EXPORT Boolean CFFileSecurityCopyAccessControlList(CFFileSecurityRef fileSec, acl_t *accessControlList); +CF_EXPORT Boolean CFFileSecuritySetAccessControlList(CFFileSecurityRef fileSec, acl_t accessControlList); +CF_EXPORT Boolean CFFileSecurityGetOwner(CFFileSecurityRef fileSec, uid_t *owner); +CF_EXPORT Boolean CFFileSecuritySetOwner(CFFileSecurityRef fileSec, uid_t owner); +CF_EXPORT Boolean CFFileSecurityGetGroup(CFFileSecurityRef fileSec, gid_t *group); +CF_EXPORT Boolean CFFileSecuritySetGroup(CFFileSecurityRef fileSec, gid_t group); +CF_EXPORT Boolean CFFileSecurityGetMode(CFFileSecurityRef fileSec, mode_t *mode); +CF_EXPORT Boolean CFFileSecuritySetMode(CFFileSecurityRef fileSec, mode_t mode); +CF_EXPORT Boolean CFFileSecurityClearProperties(CFFileSecurityRef fileSec, CFOptionFlags clearPropertyMask); + +CF_EXTERN_C_END + +#endif +#endif + diff --git a/include/CoreFoundation/CFICUConverters.h b/include/CoreFoundation/CFICUConverters.h new file mode 100644 index 0000000..a73cdcd --- /dev/null +++ b/include/CoreFoundation/CFICUConverters.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + * CFICUConverters.h + * CoreFoundation + * + * Created by Aki Inoue on 07/12/04. + * Copyright (c) 2007-2014, Apple Inc. All rights reserved. + * + */ + +#include + +CF_PRIVATE const char *__CFStringEncodingGetICUName(CFStringEncoding encoding); + +CF_PRIVATE CFStringEncoding __CFStringEncodingGetFromICUName(const char *icuName); + + +CF_PRIVATE CFIndex __CFStringEncodingICUToBytes(const char *icuName, uint32_t flags, const UniChar *characters, CFIndex numChars, CFIndex *usedCharLen, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); +CF_PRIVATE CFIndex __CFStringEncodingICUToUnicode(const char *icuName, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, CFIndex *usedByteLen, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); +CF_PRIVATE CFIndex __CFStringEncodingICUCharLength(const char *icuName, uint32_t flags, const uint8_t *bytes, CFIndex numBytes); +CF_PRIVATE CFIndex __CFStringEncodingICUByteLength(const char *icuName, uint32_t flags, const UniChar *characters, CFIndex numChars); + +// The caller is responsible for freeing the memory (use CFAllocatorDeallocate) +CF_PRIVATE CFStringEncoding *__CFStringEncodingCreateICUEncodings(CFAllocatorRef allocator, CFIndex *numberOfIndex); + + diff --git a/include/CoreFoundation/CFICULogging.h b/include/CoreFoundation/CFICULogging.h new file mode 100644 index 0000000..e4529ee --- /dev/null +++ b/include/CoreFoundation/CFICULogging.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + CFICULogging.h + Copyright (c) 2008-2014, Apple Inc. All rights reserved. +*/ + +/* + This file is for the use of the CoreFoundation project only. +*/ + +#if !defined(__COREFOUNDATION_CFICULOGGING__) +#define __COREFOUNDATION_CFICULOGGING__ 1 + +#include +#include +#include +#include +#include +#include + +// ucal + + +// ucal +#define __cficu_ucal_open ucal_open +#define __cficu_ucal_close ucal_close +#define __cficu_ucal_clone ucal_clone +#define __cficu_ucal_setAttribute ucal_setAttribute +#define __cficu_ucal_getAttribute ucal_getAttribute +#define __cficu_ucal_setGregorianChange ucal_setGregorianChange +#define __cficu_ucal_getGregorianChange ucal_getGregorianChange +#define __cficu_ucal_getMillis ucal_getMillis +#define __cficu_ucal_setMillis ucal_setMillis +#define __cficu_ucal_set ucal_set +#define __cficu_ucal_get ucal_get +#define __cficu_ucal_getDayOfWeekType ucal_getDayOfWeekType +#define __cficu_ucal_getWeekendTransition ucal_getWeekendTransition +#define __cficu_ucal_isWeekend ucal_isWeekend +#define __cficu_ucal_clear ucal_clear +#define __cficu_ucal_getLimit ucal_getLimit +#define __cficu_ucal_add ucal_add +#define __cficu_ucal_roll ucal_roll +#define __cficu_ucal_getFieldDifference ucal_getFieldDifference +#define __cficu_ucal_getNow ucal_getNow +#define __cficu_ucal_setTimeZone ucal_setTimeZone +// udatpg +#define __cficu_udatpg_open udatpg_open +#define __cficu_udatpg_close udatpg_close +#define __cficu_udatpg_getSkeleton udatpg_getSkeleton +#define __cficu_udatpg_getBestPattern udatpg_getBestPattern +// udat +#define __cficu_udat_applyPattern udat_applyPattern +#define __cficu_udat_applyPatternRelative udat_applyPatternRelative +#define __cficu_udat_clone udat_clone +#define __cficu_udat_close udat_close +#define __cficu_udat_countSymbols udat_countSymbols +#define __cficu_udat_format udat_format +#define __cficu_udat_get2DigitYearStart udat_get2DigitYearStart +#define __cficu_udat_getCalendar udat_getCalendar +#define __cficu_udat_getSymbols udat_getSymbols +#define __cficu_udat_isLenient udat_isLenient +#define __cficu_udat_open udat_open +#define __cficu_udat_parseCalendar udat_parseCalendar +#define __cficu_udat_set2DigitYearStart udat_set2DigitYearStart +#define __cficu_udat_setCalendar udat_setCalendar +#define __cficu_udat_setLenient udat_setLenient +#define __cficu_udat_setSymbols udat_setSymbols +#define __cficu_udat_toPattern udat_toPattern +#define __cficu_udat_toPatternRelativeDate udat_toPatternRelativeDate +#define __cficu_udat_toPatternRelativeTime udat_toPatternRelativeTime +#define __cficu_unum_applyPattern unum_applyPattern +#define __cficu_unum_close unum_close +#define __cficu_unum_formatDecimal unum_formatDecimal +#define __cficu_unum_formatDouble unum_formatDouble +#define __cficu_unum_getAttribute unum_getAttribute +#define __cficu_unum_getDoubleAttribute unum_getDoubleAttribute +#define __cficu_unum_getSymbol unum_getSymbol +#define __cficu_unum_getTextAttribute unum_getTextAttribute +#define __cficu_unum_open unum_open +#define __cficu_unum_parse unum_parse +#define __cficu_unum_parseDecimal unum_parseDecimal +#define __cficu_unum_setAttribute unum_setAttribute +#define __cficu_unum_setDoubleAttribute unum_setDoubleAttribute +#define __cficu_unum_setSymbol unum_setSymbol +#define __cficu_unum_setTextAttribute unum_setTextAttribute +#define __cficu_unum_toPattern unum_toPattern +#define __cficu_udat_setContext udat_setContext +#define __cficu_udat_getContext udat_getContext +// ucurr +#define __cficu_ucurr_getDefaultFractionDigits ucurr_getDefaultFractionDigits +#define __cficu_ucurr_getRoundingIncrement ucurr_getRoundingIncrement +// unum +#define __cficu_unum_setContext unum_setContext +#define __cficu_unum_getContext unum_getContext + +#endif diff --git a/include/CoreFoundation/CFInternal.h b/include/CoreFoundation/CFInternal.h new file mode 100644 index 0000000..6b8e9ed --- /dev/null +++ b/include/CoreFoundation/CFInternal.h @@ -0,0 +1,805 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFInternal.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +/* + NOT TO BE USED OUTSIDE CF! +*/ + +#if !CF_BUILDING_CF + #error The header file CFInternal.h is for the exclusive use of CoreFoundation. No other project should include it. +#endif + +#if !defined(__COREFOUNDATION_CFINTERNAL__) +#define __COREFOUNDATION_CFINTERNAL__ 1 + + +#define __CF_COMPILE_YEAR__ (__DATE__[7] * 1000 + __DATE__[8] * 100 + __DATE__[9] * 10 + __DATE__[10] - 53328) +#define __CF_COMPILE_MONTH__ ((__DATE__[1] + __DATE__[2] == 207) ? 1 : \ + (__DATE__[1] + __DATE__[2] == 199) ? 2 : \ + (__DATE__[1] + __DATE__[2] == 211) ? 3 : \ + (__DATE__[1] + __DATE__[2] == 226) ? 4 : \ + (__DATE__[1] + __DATE__[2] == 218) ? 5 : \ + (__DATE__[1] + __DATE__[2] == 227) ? 6 : \ + (__DATE__[1] + __DATE__[2] == 225) ? 7 : \ + (__DATE__[1] + __DATE__[2] == 220) ? 8 : \ + (__DATE__[1] + __DATE__[2] == 213) ? 9 : \ + (__DATE__[1] + __DATE__[2] == 215) ? 10 : \ + (__DATE__[1] + __DATE__[2] == 229) ? 11 : \ + (__DATE__[1] + __DATE__[2] == 200) ? 12 : 0) +#define __CF_COMPILE_DAY__ (__DATE__[4] * 10 + __DATE__[5] - (__DATE__[4] == ' ' ? 368 : 528)) +#define __CF_COMPILE_DATE__ (__CF_COMPILE_YEAR__ * 10000 + __CF_COMPILE_MONTH__ * 100 + __CF_COMPILE_DAY__) + +#define __CF_COMPILE_HOUR__ (__TIME__[0] * 10 + __TIME__[1] - 528) +#define __CF_COMPILE_MINUTE__ (__TIME__[3] * 10 + __TIME__[4] - 528) +#define __CF_COMPILE_SECOND__ (__TIME__[6] * 10 + __TIME__[7] - 528) +#define __CF_COMPILE_TIME__ (__CF_COMPILE_HOUR__ * 10000 + __CF_COMPILE_MINUTE__ * 100 + __CF_COMPILE_SECOND__) + +#define __CF_COMPILE_SECOND_OF_DAY__ (__CF_COMPILE_HOUR__ * 3600 + __CF_COMPILE_MINUTE__ * 60 + __CF_COMPILE_SECOND__) + +// __CF_COMPILE_DAY_OF_EPOCH__ works within Gregorian years 2001 - 2099; the epoch is of course CF's epoch +#define __CF_COMPILE_DAY_OF_EPOCH__ ((__CF_COMPILE_YEAR__ - 2001) * 365 + (__CF_COMPILE_YEAR__ - 2001) / 4 \ + + ((__DATE__[1] + __DATE__[2] == 207) ? 0 : \ + (__DATE__[1] + __DATE__[2] == 199) ? 31 : \ + (__DATE__[1] + __DATE__[2] == 211) ? 59 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ + (__DATE__[1] + __DATE__[2] == 226) ? 90 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ + (__DATE__[1] + __DATE__[2] == 218) ? 120 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ + (__DATE__[1] + __DATE__[2] == 227) ? 151 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ + (__DATE__[1] + __DATE__[2] == 225) ? 181 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ + (__DATE__[1] + __DATE__[2] == 220) ? 212 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ + (__DATE__[1] + __DATE__[2] == 213) ? 243 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ + (__DATE__[1] + __DATE__[2] == 215) ? 273 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ + (__DATE__[1] + __DATE__[2] == 229) ? 304 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ + (__DATE__[1] + __DATE__[2] == 200) ? 334 + (__CF_COMPILE_YEAR__ % 4 == 0) : \ + 365 + (__CF_COMPILE_YEAR__ % 4 == 0)) \ + + __CF_COMPILE_DAY__) + + +CF_EXTERN_C_BEGIN + +#include +#include +#include +#include +#include +#include +#include +#include +#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI || DEPLOYMENT_TARGET_LINUX +#include +#include +#include +#include +#include +#endif +#include + + +#if defined(__BIG_ENDIAN__) +#define __CF_BIG_ENDIAN__ 1 +#define __CF_LITTLE_ENDIAN__ 0 +#endif + +#if defined(__LITTLE_ENDIAN__) +#define __CF_LITTLE_ENDIAN__ 1 +#define __CF_BIG_ENDIAN__ 0 +#endif + + +#include + +CF_EXPORT const char *_CFProcessName(void); +CF_EXPORT CFStringRef _CFProcessNameString(void); + +CF_EXPORT Boolean _CFGetCurrentDirectory(char *path, int maxlen); + +CF_EXPORT CFArrayRef _CFGetWindowsBinaryDirectories(void); + +CF_EXPORT CFStringRef _CFStringCreateHostName(void); + +#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI +#include +CF_EXPORT void _CFMachPortInstallNotifyPort(CFRunLoopRef rl, CFStringRef mode); +#endif + + +CF_PRIVATE CFIndex __CFActiveProcessorCount(); + +#ifndef CLANG_ANALYZER_NORETURN +#if __has_feature(attribute_analyzer_noreturn) +#define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) +#else +#define CLANG_ANALYZER_NORETURN +#endif +#endif + +#if DEPLOYMENT_TARGET_WINDOWS +#define __builtin_unreachable() do { } while (0) +#endif + +#if defined(__i386__) || defined(__x86_64__) + #if defined(__GNUC__) + #define HALT do {asm __volatile__("int3"); kill(getpid(), 9); __builtin_unreachable(); } while (0) + #elif defined(_MSC_VER) + #define HALT do { DebugBreak(); abort(); __builtin_unreachable(); } while (0) + #else + #error Compiler not supported + #endif +#endif + + +#if defined(DEBUG) + #define __CFAssert(cond, prio, desc, a1, a2, a3, a4, a5) \ + do { \ + if (!(cond)) { \ + CFLog(prio, CFSTR(desc), a1, a2, a3, a4, a5); \ + /* HALT; */ \ + } \ + } while (0) +#else + #define __CFAssert(cond, prio, desc, a1, a2, a3, a4, a5) \ + do {} while (0) +#endif + +#define CFAssert(condition, priority, description) \ + __CFAssert((condition), (priority), description, 0, 0, 0, 0, 0) +#define CFAssert1(condition, priority, description, a1) \ + __CFAssert((condition), (priority), description, (a1), 0, 0, 0, 0) +#define CFAssert2(condition, priority, description, a1, a2) \ + __CFAssert((condition), (priority), description, (a1), (a2), 0, 0, 0) +#define CFAssert3(condition, priority, description, a1, a2, a3) \ + __CFAssert((condition), (priority), description, (a1), (a2), (a3), 0, 0) +#define CFAssert4(condition, priority, description, a1, a2, a3, a4) \ + __CFAssert((condition), (priority), description, (a1), (a2), (a3), (a4), 0) + +#define __kCFLogAssertion 3 + +// This CF-only log function uses no CF functionality, so it may be called anywhere within CF - including thread teardown or prior to full CF setup +CF_PRIVATE void _CFLogSimple(int32_t lev, char *format, ...); + +#if defined(DEBUG) +extern void __CFGenericValidateType_(CFTypeRef cf, CFTypeID type, const char *func); +#define __CFGenericValidateType(cf, type) __CFGenericValidateType_(cf, type, __PRETTY_FUNCTION__) +#else +#define __CFGenericValidateType(cf, type) ((void)0) +#endif + +#define CF_INFO_BITS (!!(__CF_BIG_ENDIAN__) * 3) +#define CF_RC_BITS (!!(__CF_LITTLE_ENDIAN__) * 3) + +/* Bit manipulation macros */ +/* Bits are numbered from 31 on left to 0 on right */ +/* May or may not work if you use them on bitfields in types other than UInt32, bitfields the full width of a UInt32, or anything else for which they were not designed. */ +/* In the following, N1 and N2 specify an inclusive range N2..N1 with N1 >= N2 */ +#define __CFBitfieldMask(N1, N2) ((((UInt32)~0UL) << (31UL - (N1) + (N2))) >> (31UL - N1)) +#define __CFBitfieldGetValue(V, N1, N2) (((V) & __CFBitfieldMask(N1, N2)) >> (N2)) +#define __CFBitfieldSetValue(V, N1, N2, X) ((V) = ((V) & ~__CFBitfieldMask(N1, N2)) | (((X) << (N2)) & __CFBitfieldMask(N1, N2))) +#define __CFBitfieldMaxValue(N1, N2) __CFBitfieldGetValue(0xFFFFFFFFUL, (N1), (N2)) + +#define __CFBitIsSet(V, N) (((V) & (1UL << (N))) != 0) +#define __CFBitSet(V, N) ((V) |= (1UL << (N))) +#define __CFBitClear(V, N) ((V) &= ~(1UL << (N))) + +// Foundation uses 20-40 +// Foundation knows about the value of __CFTSDKeyAutoreleaseData1 +enum { + __CFTSDKeyAllocator = 1, + __CFTSDKeyIsInCFLog = 2, + __CFTSDKeyIsInNSCache = 3, + __CFTSDKeyIsInGCDMainQ = 4, + __CFTSDKeyICUConverter = 7, + __CFTSDKeyCollatorLocale = 8, + __CFTSDKeyCollatorUCollator = 9, + __CFTSDKeyRunLoop = 10, + __CFTSDKeyRunLoopCntr = 11, + __CFTSDKeyMachMessageBoost = 12, // valid only in the context of a CFMachPort callout + __CFTSDKeyMachMessageHasVoucher = 13, + // autorelease pool stuff must be higher than run loop constants + __CFTSDKeyAutoreleaseData2 = 61, + __CFTSDKeyAutoreleaseData1 = 62, + __CFTSDKeyExceptionData = 63, +}; + +#define __kCFAllocatorTypeID_CONST 2 + +CF_INLINE CFAllocatorRef __CFGetDefaultAllocator(void) { + CFAllocatorRef allocator = (CFAllocatorRef)_CFGetTSD(__CFTSDKeyAllocator); + if (NULL == allocator) { + allocator = kCFAllocatorSystemDefault; + } + return allocator; +} + + +#if !defined(LLONG_MAX) + #if defined(_I64_MAX) + #define LLONG_MAX _I64_MAX + #else + #warning Arbitrarily defining LLONG_MAX + #define LLONG_MAX (int64_t)9223372036854775807 + #endif +#endif /* !defined(LLONG_MAX) */ + +#if !defined(LLONG_MIN) + #if defined(_I64_MIN) + #define LLONG_MIN _I64_MIN + #else + #warning Arbitrarily defining LLONG_MIN + #define LLONG_MIN (-LLONG_MAX - (int64_t)1) + #endif +#endif /* !defined(LLONG_MIN) */ + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) + #define __CFMin(A,B) ({__typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; }) + #define __CFMax(A,B) ({__typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) +#else /* __GNUC__ */ + #define __CFMin(A,B) ((A) < (B) ? (A) : (B)) + #define __CFMax(A,B) ((A) > (B) ? (A) : (B)) +#endif /* __GNUC__ */ + +/* Secret CFAllocator hint bits */ +#define __kCFAllocatorTempMemory 0x2 +#define __kCFAllocatorNoPointers 0x10 +#define __kCFAllocatorDoNotRecordEvent 0x100 +#define __kCFAllocatorGCScannedMemory 0x200 /* GC: memory should be scanned. */ +#define __kCFAllocatorGCObjectMemory 0x400 /* GC: memory needs to be finalized. */ + +CF_INLINE auto_memory_type_t CF_GET_GC_MEMORY_TYPE(CFOptionFlags flags) { + auto_memory_type_t type = (flags & __kCFAllocatorGCScannedMemory ? 0 : AUTO_UNSCANNED) | (flags & __kCFAllocatorGCObjectMemory ? AUTO_OBJECT : 0); + return type; +} + +CF_INLINE void __CFAssignWithWriteBarrier(void **location, void *value) { + if (kCFUseCollectableAllocator) { + objc_assign_strongCast((id)value, (id *)location); + } else { + *location = value; + } +} + +// Zero-retain count CFAllocator functions, i.e. memory that will be collected, no dealloc necessary +CF_EXPORT void *_CFAllocatorAllocateGC(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint); +CF_EXPORT void *_CFAllocatorReallocateGC(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint); +CF_EXPORT void _CFAllocatorDeallocateGC(CFAllocatorRef allocator, void *ptr); + +CF_EXPORT CFAllocatorRef _CFTemporaryMemoryAllocator(void); + +extern uint64_t __CFTimeIntervalToTSR(CFTimeInterval ti); +extern CFTimeInterval __CFTSRToTimeInterval(uint64_t tsr); +// use this instead of attempting to subtract mach_absolute_time() directly, because that can underflow and give an unexpected answer +CF_PRIVATE CFTimeInterval __CFTimeIntervalUntilTSR(uint64_t tsr); +CF_PRIVATE dispatch_time_t __CFTSRToDispatchTime(uint64_t tsr); +CF_PRIVATE uint64_t __CFTSRToNanoseconds(uint64_t tsr); + +extern CFStringRef __CFCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions); + +/* Enhanced string formatting support + */ +CF_PRIVATE CFDictionaryRef _CFStringGetFormatSpecifierConfiguration(CFStringRef aFormatString); +CF_PRIVATE CFStringRef _CFStringCopyWithFomatStringConfiguration(CFStringRef aFormatString, CFDictionaryRef formatConfiguration); +CF_PRIVATE CFStringRef _CFCopyResolvedFormatStringWithConfiguration(CFTypeRef anObject, CFDictionaryRef aConfiguration, CFDictionaryRef formatOptions); + +/* result is long long or int, depending on doLonglong +*/ +extern Boolean __CFStringScanInteger(CFStringInlineBuffer *buf, CFTypeRef locale, SInt32 *indexPtr, Boolean doLonglong, void *result); +extern Boolean __CFStringScanDouble(CFStringInlineBuffer *buf, CFTypeRef locale, SInt32 *indexPtr, double *resultPtr); +extern Boolean __CFStringScanHex(CFStringInlineBuffer *buf, SInt32 *indexPtr, unsigned *result); + +extern const char *__CFgetenv(const char *n); + +CF_PRIVATE Boolean __CFProcessIsRestricted(); + +// This is really about the availability of C99. We don't have that on Windows, but we should everywhere else. +#if DEPLOYMENT_TARGET_WINDOWS +#define STACK_BUFFER_DECL(T, N, C) T *N = (T *)_alloca((C) * sizeof(T)) +#else +#define STACK_BUFFER_DECL(T, N, C) T N[C] +#endif + + +CF_EXPORT void * __CFConstantStringClassReferencePtr; + +#ifdef __CONSTANT_CFSTRINGS__ + +#define CONST_STRING_DECL(S, V) const CFStringRef S = (const CFStringRef)__builtin___CFStringMakeConstantString(V); +#define PE_CONST_STRING_DECL(S, V) CF_PRIVATE const CFStringRef S = (const CFStringRef)__builtin___CFStringMakeConstantString(V); + +#else + +struct CF_CONST_STRING { + CFRuntimeBase _base; + uint8_t *_ptr; + uint32_t _length; +}; + +CF_EXPORT int __CFConstantStringClassReference[]; + +/* CFNetwork also has a copy of the CONST_STRING_DECL macro (for use on platforms without constant string support in cc); please warn cfnetwork-core@group.apple.com of any necessary changes to this macro. -- REW, 1/28/2002 */ + +#if __CF_BIG_ENDIAN__ + +#define CONST_STRING_DECL(S, V) \ +static struct CF_CONST_STRING __ ## S ## __ = {{(uintptr_t)&__CFConstantStringClassReference, {0x00, 0x00, 0x07, 0xc8}}, (uint8_t *)V, sizeof(V) - 1}; \ +const CFStringRef S = (CFStringRef) & __ ## S ## __; +#define PE_CONST_STRING_DECL(S, V) \ +static struct CF_CONST_STRING __ ## S ## __ = {{(uintptr_t)&__CFConstantStringClassReference, {0x00, 0x00, 0x07, 0xc8}}, (uint8_t *)V, sizeof(V) - 1}; \ +CF_PRIVATE const CFStringRef S = (CFStringRef) & __ ## S ## __; + +#elif __CF_LITTLE_ENDIAN__ + +#define CONST_STRING_DECL(S, V) \ +static struct CF_CONST_STRING __ ## S ## __ = {{(uintptr_t)&__CFConstantStringClassReference, {0xc8, 0x07, 0x00, 0x00}}, (uint8_t *)(V), sizeof(V) - 1}; \ +const CFStringRef S = (CFStringRef) & __ ## S ## __; +#define PE_CONST_STRING_DECL(S, V) \ +static struct CF_CONST_STRING __ ## S ## __ = {{(uintptr_t)&__CFConstantStringClassReference, {0xc8, 0x07, 0x00, 0x00}}, (uint8_t *)(V), sizeof(V) - 1}; \ +CF_PRIVATE const CFStringRef S = (CFStringRef) & __ ## S ## __; + +#endif + +#endif // __CONSTANT_CFSTRINGS__ + +CF_EXPORT bool __CFOASafe; +CF_EXPORT void __CFSetLastAllocationEventName(void *ptr, const char *classname); + + + +/* Comparators are passed the address of the values; this is somewhat different than CFComparatorFunction is used in public API usually. */ +CF_EXPORT CFIndex CFBSearch(const void *element, CFIndex elementSize, const void *list, CFIndex count, CFComparatorFunction comparator, void *context); + +CF_EXPORT CFHashCode CFHashBytes(UInt8 *bytes, CFIndex length); + +CF_EXPORT CFStringEncoding CFStringFileSystemEncoding(void); + +CF_PRIVATE CFStringRef __CFStringCreateImmutableFunnel3(CFAllocatorRef alloc, const void *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean possiblyExternalFormat, Boolean tryToReduceUnicode, Boolean hasLengthByte, Boolean hasNullByte, Boolean noCopy, CFAllocatorRef contentsDeallocator, UInt32 converterFlags); + +extern const void *__CFStringCollectionCopy(CFAllocatorRef allocator, const void *ptr); +extern const void *__CFTypeCollectionRetain(CFAllocatorRef allocator, const void *ptr); +extern void __CFTypeCollectionRelease(CFAllocatorRef allocator, const void *ptr); + +extern CFTypeRef CFMakeUncollectable(CFTypeRef cf); + +CF_PRIVATE void _CFRaiseMemoryException(CFStringRef reason); + +CF_PRIVATE Boolean __CFProphylacticAutofsAccess; + + +#if DEPLOYMENT_TARGET_MACOSX + +typedef pthread_mutex_t CFLock_t; + +#define CFLockInit ((pthread_mutex_t)PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) +#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit) + +#define __CFLock(LP) ({ \ + (void)pthread_mutex_lock(LP); }) + +#define __CFUnlock(LP) ({ \ + (void)pthread_mutex_unlock(LP); }) + +#define __CFLockTry(LP) ({ \ + pthread_mutex_trylock(LP) == 0; }) + +#elif DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI + +typedef pthread_mutex_t CFLock_t; + +#define CFLockInit ((pthread_mutex_t)PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) +#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit) + +#define __CFLock(LP) ({ \ + (void)pthread_mutex_lock(LP); }) + +#define __CFUnlock(LP) ({ \ + (void)pthread_mutex_unlock(LP); }) + +#define __CFLockTry(LP) ({ \ + pthread_mutex_trylock(LP) == 0; }) + +#elif DEPLOYMENT_TARGET_WINDOWS + +typedef int32_t CFLock_t; +#define CFLockInit 0 +#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit) + +CF_INLINE void __CFLock(volatile CFLock_t *lock) { + while (InterlockedCompareExchange((LONG volatile *)lock, ~0, 0) != 0) { + Sleep(0); + } +} + +CF_INLINE void __CFUnlock(volatile CFLock_t *lock) { + MemoryBarrier(); + *lock = 0; +} + +CF_INLINE Boolean __CFLockTry(volatile CFLock_t *lock) { + return (InterlockedCompareExchange((LONG volatile *)lock, ~0, 0) == 0); +} + +#elif DEPLOYMENT_TARGET_LINUX + +typedef int32_t CFLock_t; +#define CFLockInit 0 +#define CF_LOCK_INIT_FOR_STRUCTS(X) (X = CFLockInit) + +CF_INLINE void __CFLock(volatile CFLock_t *lock) { + while (__sync_val_compare_and_swap(lock, 0, ~0) != 0) { + sleep(0); + } +} + +CF_INLINE void __CFUnlock(volatile CFLock_t *lock) { + __sync_synchronize(); + *lock = 0; +} + +CF_INLINE Boolean __CFLockTry(volatile CFLock_t *lock) { + return (__sync_val_compare_and_swap(lock, 0, ~0) == 0); +} + +#else + +#warning CF locks not defined for this platform -- CF is not thread-safe +#define __CFLock(A) do {} while (0) +#define __CFUnlock(A) do {} while (0) + +#endif + + +#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI +extern uint8_t __CF120293; +extern uint8_t __CF120290; +extern void __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__(void); +#define CHECK_FOR_FORK() do { __CF120290 = true; if (__CF120293) __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__(); } while (0) +#define CHECK_FOR_FORK_RET(...) do { CHECK_FOR_FORK(); if (__CF120293) return __VA_ARGS__; } while (0) +#define HAS_FORKED() (__CF120293) +#endif + +#if !defined(CHECK_FOR_FORK) +#define CHECK_FOR_FORK() do { } while (0) +#endif + +#if !defined(CHECK_FOR_FORK_RET) +#define CHECK_FOR_FORK_RET(...) do { } while (0) +#endif + +#if !defined(HAS_FORKED) +#define HAS_FORKED() 0 +#endif + +#include + +#define thread_errno() errno +#define thread_set_errno(V) do {errno = (V);} while (0) + +extern void *__CFStartSimpleThread(void *func, void *arg); + +/* ==================== Simple file access ==================== */ +/* For dealing with abstract types. MF:!!! These ought to be somewhere else and public. */ + +CF_EXPORT CFStringRef _CFCopyExtensionForAbstractType(CFStringRef abstractType); + +/* ==================== Simple file access ==================== */ +/* These functions all act on a c-strings which must be in the file system encoding. */ + +CF_PRIVATE Boolean _CFCreateDirectory(const char *path); +CF_PRIVATE Boolean _CFRemoveDirectory(const char *path); +CF_PRIVATE Boolean _CFDeleteFile(const char *path); + +CF_PRIVATE Boolean _CFReadBytesFromFile(CFAllocatorRef alloc, CFURLRef url, void **bytes, CFIndex *length, CFIndex maxLength, int extraOpenFlags); + /* resulting bytes are allocated from alloc which MUST be non-NULL. */ + /* maxLength of zero means the whole file. Otherwise it sets a limit on the number of bytes read. */ + +CF_EXPORT Boolean _CFWriteBytesToFile(CFURLRef url, const void *bytes, CFIndex length); + +CF_PRIVATE CFMutableArrayRef _CFCreateContentsOfDirectory(CFAllocatorRef alloc, char *dirPath, void *dirSpec, CFURLRef dirURL, CFStringRef matchingAbstractType); + /* On Mac OS 8/9, one of dirSpec, dirPath and dirURL must be non-NULL */ + /* On all other platforms, one of path and dirURL must be non-NULL */ + /* If both are present, they are assumed to be in-synch; that is, they both refer to the same directory. */ + /* alloc may be NULL */ + /* return value is CFArray of CFURLs */ + +CF_PRIVATE SInt32 _CFGetPathProperties(CFAllocatorRef alloc, char *path, Boolean *exists, SInt32 *posixMode, SInt64 *size, CFDateRef *modTime, SInt32 *ownerID, CFArrayRef *dirContents); + /* alloc may be NULL */ + /* any of exists, posixMode, size, modTime, and dirContents can be NULL. Usually it is not a good idea to pass NULL for exists, since interpretting the other values sometimes requires that you know whether the file existed or not. Except for dirContents, it is pretty cheap to compute any of these things as loing as one of them must be computed. */ + +CF_PRIVATE SInt32 _CFGetFileProperties(CFAllocatorRef alloc, CFURLRef pathURL, Boolean *exists, SInt32 *posixMode, SInt64 *size, CFDateRef *modTime, SInt32 *ownerID, CFArrayRef *dirContents); + /* alloc may be NULL */ + /* any of exists, posixMode, size, modTime, and dirContents can be NULL. Usually it is not a good idea to pass NULL for exists, since interpretting the other values sometimes requires that you know whether the file existed or not. Except for dirContents, it is pretty cheap to compute any of these things as loing as one of them must be computed. */ + + +/* ==================== Simple path manipulation ==================== */ + +CF_EXPORT UniChar _CFGetSlash(); +CF_PRIVATE CFStringRef _CFGetSlashStr(); +CF_EXPORT Boolean _CFIsAbsolutePath(UniChar *unichars, CFIndex length); +CF_PRIVATE void _CFAppendTrailingPathSlash2(CFMutableStringRef path); +CF_PRIVATE void _CFAppendConditionalTrailingPathSlash2(CFMutableStringRef path); +CF_EXPORT Boolean _CFAppendPathComponent(UniChar *unichars, CFIndex *length, CFIndex maxLength, UniChar *component, CFIndex componentLength); +CF_PRIVATE void _CFAppendPathComponent2(CFMutableStringRef path, CFStringRef component); +CF_PRIVATE Boolean _CFAppendPathExtension2(CFMutableStringRef path, CFStringRef extension); +CF_EXPORT Boolean _CFAppendPathExtension(UniChar *unichars, CFIndex *length, CFIndex maxLength, UniChar *extension, CFIndex extensionLength); +CF_EXPORT Boolean _CFTransmutePathSlashes(UniChar *unichars, CFIndex *length, UniChar replSlash); +CF_PRIVATE CFStringRef _CFCreateLastPathComponent(CFAllocatorRef alloc, CFStringRef path, CFIndex *slashIndex); +CF_EXPORT CFIndex _CFStartOfLastPathComponent(UniChar *unichars, CFIndex length); +CF_PRIVATE CFIndex _CFStartOfLastPathComponent2(CFStringRef path); +CF_EXPORT CFIndex _CFLengthAfterDeletingLastPathComponent(UniChar *unichars, CFIndex length); +CF_PRIVATE CFIndex _CFLengthAfterDeletingPathExtension2(CFStringRef path); +CF_EXPORT CFIndex _CFStartOfPathExtension(UniChar *unichars, CFIndex length); +CF_PRIVATE CFIndex _CFStartOfPathExtension2(CFStringRef path); +CF_EXPORT CFIndex _CFLengthAfterDeletingPathExtension(UniChar *unichars, CFIndex length); + +#if __BLOCKS__ +#if DEPLOYMENT_TARGET_WINDOWS +#define DT_DIR 4 +#define DT_REG 8 +#define DT_LNK 10 +#endif + +// This function automatically skips '.' and '..', and '._' files +CF_PRIVATE void _CFIterateDirectory(CFStringRef directoryPath, Boolean (^fileHandler)(CFStringRef fileName, uint8_t fileType)); +#endif + +#define __CFMaxRuntimeTypes 65535 +#define __CFRuntimeClassTableSize 1024 + +extern void _CFRuntimeSetInstanceTypeIDAndIsa(CFTypeRef cf, CFTypeID newTypeID); + +#define CF_OBJC_FUNCDISPATCHV(typeID, obj, ...) do { } while (0) +#define CF_OBJC_CALLV(obj, ...) (0) +#define CF_IS_OBJC(typeID, obj) (0) +#define __CFISAForTypeID(t) (0) + +/* See comments in CFBase.c +*/ +#define FAULT_CALLBACK(V) +#define INVOKE_CALLBACK1(P, A) (P)(A) +#define INVOKE_CALLBACK2(P, A, B) (P)(A, B) +#define INVOKE_CALLBACK3(P, A, B, C) (P)(A, B, C) +#define INVOKE_CALLBACK4(P, A, B, C, D) (P)(A, B, C, D) +#define INVOKE_CALLBACK5(P, A, B, C, D, E) (P)(A, B, C, D, E) +#define UNFAULT_CALLBACK(V) do { } while (0) + +/* For the support of functionality which needs CarbonCore or other frameworks */ +// These macros define an upcall or weak "symbol-lookup" wrapper function. +// The parameters are: +// R : the return type of the function +// N : the name of the function (in the other library) +// P : the parenthesized parameter list of the function +// A : the parenthesized actual argument list to be passed +// FAILACTION: (only for the _FAIL macros) additional code to be +// run when the function cannot be found. +// opt: a fifth optional argument can be passed in which is the +// return value of the wrapper when the function cannot be +// found; should be of type R, & can be a function call +// The name of the resulting wrapper function is: +// __CFCarbonCore_N (where N is the second parameter) +// __CFNetwork_N (where N is the second parameter) +// +// Example: +// DEFINE_WEAK_CARBONCORE_FUNC(void, DisposeHandle, (Handle h), (h)) +// + +#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED + +extern void *__CFLookupCFNetworkFunction(const char *name); + +#define DEFINE_WEAK_CFNETWORK_FUNC(R, N, P, A, ...) \ + typedef R (*dyfuncptr)P; \ + static dyfuncptr dyfunc = (dyfuncptr)(~(uintptr_t)0); \ + if ((dyfuncptr)(~(uintptr_t)0) == dyfunc) { \ + dyfunc = (dyfuncptr)__CFLookupCFNetworkFunction(#N); } \ + if (dyfunc) { return dyfunc A ; } \ + return __VA_ARGS__ ; \ +} + +#define DEFINE_WEAK_CFNETWORK_FUNC_FAIL(R, N, P, A, FAILACTION, ...) \ +static R __CFNetwork_ ## N P { \ + typedef R (*dyfuncptr)P; \ + static dyfuncptr dyfunc = (dyfuncptr)(~(uintptr_t)0); \ + if ((dyfuncptr)(~(uintptr_t)0) == dyfunc) { \ + dyfunc = (dyfuncptr)__CFLookupCFNetworkFunction(#N); } \ + if (dyfunc) { return dyfunc A ; } \ + FAILACTION ; \ + return __VA_ARGS__ ; \ +} + +#else +#define DEFINE_WEAK_CFNETWORK_FUNC(R, N, P, A, ...) +#define DEFINE_WEAK_CFNETWORK_FUNC_FAIL(R, N, P, A, ...) +#endif + +#define DEFINE_WEAK_CARBONCORE_FUNC(R, N, P, A, ...) + +#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED + +extern void *__CFLookupCoreServicesInternalFunction(const char *name); + +#define DEFINE_WEAK_CORESERVICESINTERNAL_FUNC(R, N, P, A, ...) \ + static R __CFCoreServicesInternal_ ## N P { \ + typedef R (*dyfuncptr)P; \ + static dyfuncptr dyfunc = (dyfuncptr)(~(uintptr_t)0); \ + if ((dyfuncptr)(~(uintptr_t)0) == dyfunc) { \ + dyfunc = (dyfuncptr)__CFLookupCoreServicesInternalFunction(#N); \ + } \ + if (dyfunc) { \ + return dyfunc A ; \ + } \ + return __VA_ARGS__ ; \ + } + +#else +#define DEFINE_WEAK_CORESERVICESINTERNAL_FUNC(R, N, P, A, ...) +#endif + +CF_PRIVATE CFComparisonResult _CFCompareStringsWithLocale(CFStringInlineBuffer *str1, CFRange str1Range, CFStringInlineBuffer *str2, CFRange str2Range, CFOptionFlags options, const void *compareLocale); + + +CF_PRIVATE CFArrayRef _CFBundleCopyUserLanguages(); + + +// This should only be used in CF types, not toll-free bridged objects! +// It should not be used with CFAllocator arguments! +// Use CFGetAllocator() in the general case, and this inline function in a few limited (but often called) situations. +CF_INLINE CFAllocatorRef __CFGetAllocator(CFTypeRef cf) { // !!! Use with CF types only, and NOT WITH CFAllocator! +#if OBJC_HAVE_TAGGED_POINTERS + if (_objc_isTaggedPointer(cf)) { + return kCFAllocatorSystemDefault; + } +#endif + if (__builtin_expect(__CFBitfieldGetValue(((const CFRuntimeBase *)cf)->_cfinfo[CF_INFO_BITS], 7, 7), 1)) { + return kCFAllocatorSystemDefault; + } + return *(CFAllocatorRef *)((char *)cf - sizeof(CFAllocatorRef)); +} + +/* !!! Avoid #importing objc.h; e.g. converting this to a .m file */ +struct __objcFastEnumerationStateEquivalent { + unsigned long state; + unsigned long *itemsPtr; + unsigned long *mutationsPtr; + unsigned long extra[5]; +}; + +#if 0 +#pragma mark - +#pragma mark Windows Compatability +#endif + +// Need to use the _O_BINARY flag on Windows to get the correct behavior +#if DEPLOYMENT_TARGET_WINDOWS +#define CF_OPENFLGS (_O_BINARY|_O_NOINHERIT) +#else +#define CF_OPENFLGS (0) +#endif + +#if DEPLOYMENT_TARGET_WINDOWS + +// These are replacements for pthread calls on Windows +CF_EXPORT int _NS_pthread_main_np(); +CF_EXPORT int _NS_pthread_setspecific(pthread_key_t key, const void *val); +CF_EXPORT void* _NS_pthread_getspecific(pthread_key_t key); +CF_EXPORT int _NS_pthread_key_init_np(int key, void (*destructor)(void *)); +CF_EXPORT void _NS_pthread_setname_np(const char *name); + +// map use of pthread_set/getspecific to internal API +#define pthread_setspecific _NS_pthread_setspecific +#define pthread_getspecific _NS_pthread_getspecific +#define pthread_key_init_np _NS_pthread_key_init_np +#define pthread_main_np _NS_pthread_main_np +#define pthread_setname_np _NS_pthread_setname_np +#endif + +#if DEPLOYMENT_TARGET_WINDOWS +// replacement for DISPATCH_QUEUE_OVERCOMMIT until we get a bug fix in dispatch on Windows +// dispatch on Windows: Need queue_private.h +#define DISPATCH_QUEUE_OVERCOMMIT 2 +#endif + +#if DEPLOYMENT_TARGET_WINDOWS +CF_PRIVATE const wchar_t *_CFDLLPath(void); +#endif + +/* Buffer size for file pathname */ +#if DEPLOYMENT_TARGET_WINDOWS +#define CFMaxPathSize ((CFIndex)262) +#define CFMaxPathLength ((CFIndex)260) +#define PATH_SEP '\\' +#define PATH_SEP_STR CFSTR("\\") +#define PATH_MAX MAX_PATH +#else +#define CFMaxPathSize ((CFIndex)1026) +#define CFMaxPathLength ((CFIndex)1024) +#define PATH_SEP '/' +#define PATH_SEP_STR CFSTR("/") +#endif + +CF_INLINE const char *CFPathRelativeToAppleFrameworksRoot(const char *path, Boolean *allocated) { + if (path) { + const char *platformRoot = __CFgetenv("APPLE_FRAMEWORKS_ROOT"); + if (platformRoot) { + char *newPath = NULL; + asprintf(&newPath, "%s%s", platformRoot, path); + if (allocated && newPath) { + *allocated = true; + } + return newPath; + } + } + if (allocated) { + *allocated = false; + } + return path; +} + +#include +#include + +#if (DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED) + +// Returns a generic dispatch queue for when you want to just throw some work +// into the concurrent pile to execute, and don't care about specifics except +// to match the QOS of the main thread. +CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericMatchingMain(void) { + return dispatch_get_global_queue(qos_class_main(), DISPATCH_QUEUE_OVERCOMMIT); +} + +// Returns a generic dispatch queue for when you want to just throw some work +// into the concurrent pile to execute, and don't care about specifics except +// to match the QOS of the current thread. +CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericMatchingCurrent(void) { + return dispatch_get_global_queue(qos_class_self(), 0); // DISPATCH_QUEUE_OVERCOMMIT left out intentionally at this point +} + +// Returns a generic dispatch queue for when you want to just throw some work +// into the concurrent pile to execute, and don't care about specifics except +// that it should be in background QOS. +CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericBackground(void) { + // Don't ACTUALLY use BACKGROUND, because of unknowable and unfavorable interactions like () + return dispatch_get_global_queue(QOS_CLASS_UTILITY, DISPATCH_QUEUE_OVERCOMMIT); +} + +#else + +CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericMatchingMain(void) { + return dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, DISPATCH_QUEUE_OVERCOMMIT); +} + +CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericMatchingCurrent(void) { + return dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0); // DISPATCH_QUEUE_OVERCOMMIT left out intentionally at this point +} + +CF_INLINE dispatch_queue_t __CFDispatchQueueGetGenericBackground(void) { + return dispatch_get_global_queue(QOS_CLASS_UTILITY, DISPATCH_QUEUE_OVERCOMMIT); +} + +#endif + + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFINTERNAL__ */ + diff --git a/include/CoreFoundation/CFLocale.h b/include/CoreFoundation/CFLocale.h new file mode 100644 index 0000000..cf7010f --- /dev/null +++ b/include/CoreFoundation/CFLocale.h @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFLocale.h + Copyright (c) 2002-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFLOCALE__) +#define __COREFOUNDATION_CFLOCALE__ 1 + +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef const struct CF_BRIDGED_TYPE(NSLocale) __CFLocale *CFLocaleRef; + +CF_EXPORT +CFTypeID CFLocaleGetTypeID(void); + +CF_EXPORT +CFLocaleRef CFLocaleGetSystem(void); + // Returns the "root", canonical locale. Contains fixed "backstop" settings. + +CF_EXPORT +CFLocaleRef CFLocaleCopyCurrent(void); + // Returns the logical "user" locale for the current user. + // [This is Copy in the sense that you get a retain you have to release, + // but we may return the same cached object over and over.] Settings + // you get from this locale do not change under you as CFPreferences + // are changed (for safety and correctness). Generally you would not + // grab this and hold onto it forever, but use it to do the operations + // you need to do at the moment, then throw it away. (The non-changing + // ensures that all the results of your operations are consistent.) + +CF_EXPORT +CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void); + // Returns an array of CFStrings that represents all locales for + // which locale data is available. + +CF_EXPORT +CFArrayRef CFLocaleCopyISOLanguageCodes(void); + // Returns an array of CFStrings that represents all known legal ISO + // language codes. Note: many of these will not have any supporting + // locale data in Mac OS X. + +CF_EXPORT +CFArrayRef CFLocaleCopyISOCountryCodes(void); + // Returns an array of CFStrings that represents all known legal ISO + // country codes. Note: many of these will not have any supporting + // locale data in Mac OS X. + +CF_EXPORT +CFArrayRef CFLocaleCopyISOCurrencyCodes(void); + // Returns an array of CFStrings that represents all known legal ISO + // currency codes. Note: some of these currencies may be obsolete, or + // represent other financial instruments. + +CF_EXPORT +CFArrayRef CFLocaleCopyCommonISOCurrencyCodes(void) CF_AVAILABLE(10_5, 2_0); + // Returns an array of CFStrings that represents ISO currency codes for + // currencies in common use. + +CF_EXPORT +CFArrayRef CFLocaleCopyPreferredLanguages(void) CF_AVAILABLE(10_5, 2_0); + // Returns the array of canonicalized CFString locale IDs that the user prefers. + +CF_EXPORT +CFStringRef CFLocaleCreateCanonicalLanguageIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier); + // Map an arbitrary language identification string (something close at + // least) to a canonical language identifier. + +CF_EXPORT +CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier); + // Map an arbitrary locale identification string (something close at + // least) to the canonical identifier. + +CF_EXPORT +CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(CFAllocatorRef allocator, LangCode lcode, RegionCode rcode); + // Map a Mac OS LangCode and RegionCode to the canonical locale identifier. + +CF_EXPORT +CFStringRef CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode(CFAllocatorRef allocator, uint32_t lcid) CF_AVAILABLE(10_6, 4_0); + // Map a Windows LCID to the canonical locale identifier. + +CF_EXPORT +uint32_t CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier(CFStringRef localeIdentifier) CF_AVAILABLE(10_6, 4_0); + // Map a locale identifier to a Windows LCID. + +typedef CF_ENUM(CFIndex, CFLocaleLanguageDirection) { + kCFLocaleLanguageDirectionUnknown = 0, + kCFLocaleLanguageDirectionLeftToRight = 1, + kCFLocaleLanguageDirectionRightToLeft = 2, + kCFLocaleLanguageDirectionTopToBottom = 3, + kCFLocaleLanguageDirectionBottomToTop = 4 +}; + +CF_EXPORT +CFLocaleLanguageDirection CFLocaleGetLanguageCharacterDirection(CFStringRef isoLangCode) CF_AVAILABLE(10_6, 4_0); + +CF_EXPORT +CFLocaleLanguageDirection CFLocaleGetLanguageLineDirection(CFStringRef isoLangCode) CF_AVAILABLE(10_6, 4_0); + +CF_EXPORT +CFDictionaryRef CFLocaleCreateComponentsFromLocaleIdentifier(CFAllocatorRef allocator, CFStringRef localeID); + // Parses a locale ID consisting of language, script, country, variant, + // and keyword/value pairs into a dictionary. The keys are the constant + // CFStrings corresponding to the locale ID components, and the values + // will correspond to constants where available. + // Example: "en_US@calendar=japanese" yields a dictionary with three + // entries: kCFLocaleLanguageCode=en, kCFLocaleCountryCode=US, and + // kCFLocaleCalendarIdentifier=kCFJapaneseCalendar. + +CF_EXPORT +CFStringRef CFLocaleCreateLocaleIdentifierFromComponents(CFAllocatorRef allocator, CFDictionaryRef dictionary); + // Reverses the actions of CFLocaleCreateDictionaryFromLocaleIdentifier, + // creating a single string from the data in the dictionary. The + // dictionary {kCFLocaleLanguageCode=en, kCFLocaleCountryCode=US, + // kCFLocaleCalendarIdentifier=kCFJapaneseCalendar} becomes + // "en_US@calendar=japanese". + +CF_EXPORT +CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator, CFStringRef localeIdentifier); + // Returns a CFLocaleRef for the locale named by the "arbitrary" locale identifier. + +CF_EXPORT +CFLocaleRef CFLocaleCreateCopy(CFAllocatorRef allocator, CFLocaleRef locale); + // Having gotten a CFLocale from somebody, code should make a copy + // if it is going to use it for several operations + // or hold onto it. In the future, there may be mutable locales. + +CF_EXPORT +CFStringRef CFLocaleGetIdentifier(CFLocaleRef locale); + // Returns the locale's identifier. This may not be the same string + // that the locale was created with (CFLocale may canonicalize it). + +CF_EXPORT +CFTypeRef CFLocaleGetValue(CFLocaleRef locale, CFStringRef key); + // Returns the value for the given key. This is how settings and state + // are accessed via a CFLocale. Values might be of any CF type. + +CF_EXPORT +CFStringRef CFLocaleCopyDisplayNameForPropertyValue(CFLocaleRef displayLocale, CFStringRef key, CFStringRef value); + // Returns the display name for the given value. The key tells what + // the value is, and is one of the usual locale property keys, though + // not all locale property keys have values with display name values. + + +CF_EXPORT const CFStringRef kCFLocaleCurrentLocaleDidChangeNotification CF_AVAILABLE(10_5, 2_0); + + +// Locale Keys +CF_EXPORT const CFStringRef kCFLocaleIdentifier; +CF_EXPORT const CFStringRef kCFLocaleLanguageCode; +CF_EXPORT const CFStringRef kCFLocaleCountryCode; +CF_EXPORT const CFStringRef kCFLocaleScriptCode; +CF_EXPORT const CFStringRef kCFLocaleVariantCode; + +CF_EXPORT const CFStringRef kCFLocaleExemplarCharacterSet; +CF_EXPORT const CFStringRef kCFLocaleCalendarIdentifier; +CF_EXPORT const CFStringRef kCFLocaleCalendar; +CF_EXPORT const CFStringRef kCFLocaleCollationIdentifier; +CF_EXPORT const CFStringRef kCFLocaleUsesMetricSystem; +CF_EXPORT const CFStringRef kCFLocaleMeasurementSystem; // "Metric" or "U.S." +CF_EXPORT const CFStringRef kCFLocaleDecimalSeparator; +CF_EXPORT const CFStringRef kCFLocaleGroupingSeparator; +CF_EXPORT const CFStringRef kCFLocaleCurrencySymbol; +CF_EXPORT const CFStringRef kCFLocaleCurrencyCode; // ISO 3-letter currency code +CF_EXPORT const CFStringRef kCFLocaleCollatorIdentifier CF_AVAILABLE(10_6, 4_0); +CF_EXPORT const CFStringRef kCFLocaleQuotationBeginDelimiterKey CF_AVAILABLE(10_6, 4_0); +CF_EXPORT const CFStringRef kCFLocaleQuotationEndDelimiterKey CF_AVAILABLE(10_6, 4_0); +CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationBeginDelimiterKey CF_AVAILABLE(10_6, 4_0); +CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationEndDelimiterKey CF_AVAILABLE(10_6, 4_0); + +// Values for kCFLocaleCalendarIdentifier +CF_EXPORT const CFStringRef kCFGregorianCalendar; +CF_EXPORT const CFStringRef kCFBuddhistCalendar; +CF_EXPORT const CFStringRef kCFChineseCalendar; +CF_EXPORT const CFStringRef kCFHebrewCalendar; +CF_EXPORT const CFStringRef kCFIslamicCalendar; +CF_EXPORT const CFStringRef kCFIslamicCivilCalendar; +CF_EXPORT const CFStringRef kCFJapaneseCalendar; +CF_EXPORT const CFStringRef kCFRepublicOfChinaCalendar CF_AVAILABLE(10_6, 4_0); +CF_EXPORT const CFStringRef kCFPersianCalendar CF_AVAILABLE(10_6, 4_0); +CF_EXPORT const CFStringRef kCFIndianCalendar CF_AVAILABLE(10_6, 4_0); +CF_EXPORT const CFStringRef kCFISO8601Calendar CF_AVAILABLE(10_6, 4_0); +CF_EXPORT const CFStringRef kCFIslamicTabularCalendar CF_AVAILABLE(10_10, 8_0); +CF_EXPORT const CFStringRef kCFIslamicUmmAlQuraCalendar CF_AVAILABLE(10_10, 8_0); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFLOCALE__ */ + diff --git a/include/CoreFoundation/CFLocaleInternal.h b/include/CoreFoundation/CFLocaleInternal.h new file mode 100644 index 0000000..fa17aa0 --- /dev/null +++ b/include/CoreFoundation/CFLocaleInternal.h @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + CFLocaleInternal.h + Copyright (c) 2008-2014, Apple Inc. All rights reserved. + */ + +/* + This file is for the use of the CoreFoundation project only. + */ + +#include + +CF_EXPORT CFStringRef const kCFLocaleAlternateQuotationBeginDelimiterKey; +CF_EXPORT CFStringRef const kCFLocaleAlternateQuotationEndDelimiterKey; +CF_EXPORT CFStringRef const kCFLocaleQuotationBeginDelimiterKey; +CF_EXPORT CFStringRef const kCFLocaleQuotationEndDelimiterKey; +CF_EXPORT CFStringRef const kCFLocaleCalendarIdentifierKey; // *** +CF_EXPORT CFStringRef const kCFLocaleCalendarKey; +CF_EXPORT CFStringRef const kCFLocaleCollationIdentifierKey; // *** +CF_EXPORT CFStringRef const kCFLocaleCollatorIdentifierKey; +CF_EXPORT CFStringRef const kCFLocaleCountryCodeKey; +CF_EXPORT CFStringRef const kCFLocaleCurrencyCodeKey; // *** +CF_EXPORT CFStringRef const kCFLocaleCurrencySymbolKey; +CF_EXPORT CFStringRef const kCFLocaleDecimalSeparatorKey; +CF_EXPORT CFStringRef const kCFLocaleExemplarCharacterSetKey; +CF_EXPORT CFStringRef const kCFLocaleGroupingSeparatorKey; +CF_EXPORT CFStringRef const kCFLocaleIdentifierKey; +CF_EXPORT CFStringRef const kCFLocaleLanguageCodeKey; +CF_EXPORT CFStringRef const kCFLocaleMeasurementSystemKey; +CF_EXPORT CFStringRef const kCFLocaleScriptCodeKey; +CF_EXPORT CFStringRef const kCFLocaleUsesMetricSystemKey; +CF_EXPORT CFStringRef const kCFLocaleVariantCodeKey; + +CF_EXPORT CFStringRef const kCFDateFormatterAMSymbolKey; +CF_EXPORT CFStringRef const kCFDateFormatterCalendarKey; +CF_EXPORT CFStringRef const kCFDateFormatterCalendarIdentifierKey; +CF_EXPORT CFStringRef const kCFDateFormatterDefaultDateKey; +CF_EXPORT CFStringRef const kCFDateFormatterDefaultFormatKey; +CF_EXPORT CFStringRef const kCFDateFormatterDoesRelativeDateFormattingKey; +CF_EXPORT CFStringRef const kCFDateFormatterEraSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterGregorianStartDateKey; +CF_EXPORT CFStringRef const kCFDateFormatterIsLenientKey; +CF_EXPORT CFStringRef const kCFDateFormatterLongEraSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterMonthSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterPMSymbolKey; +CF_EXPORT CFStringRef const kCFDateFormatterAmbiguousYearStrategyKey; +CF_EXPORT CFStringRef const kCFDateFormatterQuarterSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterShortMonthSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterShortQuarterSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterShortStandaloneMonthSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterShortStandaloneQuarterSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterShortStandaloneWeekdaySymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterShortWeekdaySymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterStandaloneMonthSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterStandaloneQuarterSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterStandaloneWeekdaySymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterTimeZoneKey; +CF_EXPORT CFStringRef const kCFDateFormatterTwoDigitStartDateKey; +CF_EXPORT CFStringRef const kCFDateFormatterVeryShortMonthSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterVeryShortStandaloneMonthSymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterVeryShortStandaloneWeekdaySymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterVeryShortWeekdaySymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterWeekdaySymbolsKey; +CF_EXPORT CFStringRef const kCFDateFormatterUsesCharacterDirectionKey; + +CF_EXPORT CFStringRef const kCFNumberFormatterAlwaysShowDecimalSeparatorKey; +CF_EXPORT CFStringRef const kCFNumberFormatterCurrencyCodeKey; +CF_EXPORT CFStringRef const kCFNumberFormatterCurrencyDecimalSeparatorKey; +CF_EXPORT CFStringRef const kCFNumberFormatterCurrencyGroupingSeparatorKey; +CF_EXPORT CFStringRef const kCFNumberFormatterCurrencySymbolKey; +CF_EXPORT CFStringRef const kCFNumberFormatterDecimalSeparatorKey; +CF_EXPORT CFStringRef const kCFNumberFormatterDefaultFormatKey; +CF_EXPORT CFStringRef const kCFNumberFormatterExponentSymbolKey; +CF_EXPORT CFStringRef const kCFNumberFormatterFormatWidthKey; +CF_EXPORT CFStringRef const kCFNumberFormatterGroupingSeparatorKey; +CF_EXPORT CFStringRef const kCFNumberFormatterGroupingSizeKey; +CF_EXPORT CFStringRef const kCFNumberFormatterInfinitySymbolKey; +CF_EXPORT CFStringRef const kCFNumberFormatterInternationalCurrencySymbolKey; +CF_EXPORT CFStringRef const kCFNumberFormatterIsLenientKey; +CF_EXPORT CFStringRef const kCFNumberFormatterMaxFractionDigitsKey; +CF_EXPORT CFStringRef const kCFNumberFormatterMaxIntegerDigitsKey; +CF_EXPORT CFStringRef const kCFNumberFormatterMaxSignificantDigitsKey; +CF_EXPORT CFStringRef const kCFNumberFormatterMinFractionDigitsKey; +CF_EXPORT CFStringRef const kCFNumberFormatterMinIntegerDigitsKey; +CF_EXPORT CFStringRef const kCFNumberFormatterMinSignificantDigitsKey; +CF_EXPORT CFStringRef const kCFNumberFormatterMinusSignKey; +CF_EXPORT CFStringRef const kCFNumberFormatterMultiplierKey; +CF_EXPORT CFStringRef const kCFNumberFormatterNaNSymbolKey; +CF_EXPORT CFStringRef const kCFNumberFormatterNegativePrefixKey; +CF_EXPORT CFStringRef const kCFNumberFormatterNegativeSuffixKey; +CF_EXPORT CFStringRef const kCFNumberFormatterPaddingCharacterKey; +CF_EXPORT CFStringRef const kCFNumberFormatterPaddingPositionKey; +CF_EXPORT CFStringRef const kCFNumberFormatterPerMillSymbolKey; +CF_EXPORT CFStringRef const kCFNumberFormatterPercentSymbolKey; +CF_EXPORT CFStringRef const kCFNumberFormatterPlusSignKey; +CF_EXPORT CFStringRef const kCFNumberFormatterPositivePrefixKey; +CF_EXPORT CFStringRef const kCFNumberFormatterPositiveSuffixKey; +CF_EXPORT CFStringRef const kCFNumberFormatterRoundingIncrementKey; +CF_EXPORT CFStringRef const kCFNumberFormatterRoundingModeKey; +CF_EXPORT CFStringRef const kCFNumberFormatterSecondaryGroupingSizeKey; +CF_EXPORT CFStringRef const kCFNumberFormatterUseGroupingSeparatorKey; +CF_EXPORT CFStringRef const kCFNumberFormatterUseSignificantDigitsKey; +CF_EXPORT CFStringRef const kCFNumberFormatterZeroSymbolKey; +CF_EXPORT CFStringRef const kCFNumberFormatterUsesCharacterDirectionKey; + +CF_EXPORT CFStringRef const kCFCalendarIdentifierGregorian; +CF_EXPORT CFStringRef const kCFCalendarIdentifierBuddhist; +CF_EXPORT CFStringRef const kCFCalendarIdentifierJapanese; +CF_EXPORT CFStringRef const kCFCalendarIdentifierIslamic; +CF_EXPORT CFStringRef const kCFCalendarIdentifierIslamicCivil; +CF_EXPORT CFStringRef const kCFCalendarIdentifierIslamicTabular; +CF_EXPORT CFStringRef const kCFCalendarIdentifierIslamicUmmAlQura; +CF_EXPORT CFStringRef const kCFCalendarIdentifierHebrew; +CF_EXPORT CFStringRef const kCFCalendarIdentifierChinese; +CF_EXPORT CFStringRef const kCFCalendarIdentifierRepublicOfChina; +CF_EXPORT CFStringRef const kCFCalendarIdentifierPersian; +CF_EXPORT CFStringRef const kCFCalendarIdentifierIndian; +CF_EXPORT CFStringRef const kCFCalendarIdentifierISO8601; +CF_EXPORT CFStringRef const kCFCalendarIdentifierCoptic; +CF_EXPORT CFStringRef const kCFCalendarIdentifierEthiopicAmeteMihret; +CF_EXPORT CFStringRef const kCFCalendarIdentifierEthiopicAmeteAlem; + + diff --git a/include/CoreFoundation/CFLogUtilities.h b/include/CoreFoundation/CFLogUtilities.h new file mode 100644 index 0000000..694a931 --- /dev/null +++ b/include/CoreFoundation/CFLogUtilities.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFLogUtilities.h + Copyright (c) 2004-2014, Apple Inc. All rights reserved. +*/ + +/* + APPLE SPI: NOT TO BE USED OUTSIDE APPLE! +*/ + +#if !defined(__COREFOUNDATION_CFLOGUTILITIES__) +#define __COREFOUNDATION_CFLOGUTILITIES__ 1 + +#include +#include + +CF_EXTERN_C_BEGIN + + +enum { // Legal level values for CFLog() + kCFLogLevelEmergency = 0, + kCFLogLevelAlert = 1, + kCFLogLevelCritical = 2, + kCFLogLevelError = 3, + kCFLogLevelWarning = 4, + kCFLogLevelNotice = 5, + kCFLogLevelInfo = 6, + kCFLogLevelDebug = 7, +}; + +CF_EXPORT void CFLog(int32_t level, CFStringRef format, ...); +/* Passing in a level value which is outside the range of 0-7 will cause the the call to do nothing. + CFLog() logs the message using the asl.h API, and uses the level parameter as the log level. + Note that the asl subsystem ignores some log levels by default. + CFLog() is not fast, and is not going to be guaranteed to be fast. + Even "no-op" CFLogs are not necessarily fast. + If you care about performance, you shouldn't be logging. +*/ + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFLOGUTILITIES__ */ + diff --git a/include/CoreFoundation/CFMachPort.h b/include/CoreFoundation/CFMachPort.h new file mode 100644 index 0000000..40d15ab --- /dev/null +++ b/include/CoreFoundation/CFMachPort.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFMachPort.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFMACHPORT__) +#define __COREFOUNDATION_CFMACHPORT__ 1 + +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMachPort) __CFMachPort * CFMachPortRef; + +typedef struct { + CFIndex version; + void * info; + const void *(*retain)(const void *info); + void (*release)(const void *info); + CFStringRef (*copyDescription)(const void *info); +} CFMachPortContext; + +typedef void (*CFMachPortCallBack)(CFMachPortRef port, void *msg, CFIndex size, void *info); +typedef void (*CFMachPortInvalidationCallBack)(CFMachPortRef port, void *info); + +CF_EXPORT CFTypeID CFMachPortGetTypeID(void); + +CF_EXPORT CFMachPortRef CFMachPortCreate(CFAllocatorRef allocator, CFMachPortCallBack callout, CFMachPortContext *context, Boolean *shouldFreeInfo); +CF_EXPORT CFMachPortRef CFMachPortCreateWithPort(CFAllocatorRef allocator, mach_port_t portNum, CFMachPortCallBack callout, CFMachPortContext *context, Boolean *shouldFreeInfo); + +CF_EXPORT mach_port_t CFMachPortGetPort(CFMachPortRef port); +CF_EXPORT void CFMachPortGetContext(CFMachPortRef port, CFMachPortContext *context); +CF_EXPORT void CFMachPortInvalidate(CFMachPortRef port); +CF_EXPORT Boolean CFMachPortIsValid(CFMachPortRef port); +CF_EXPORT CFMachPortInvalidationCallBack CFMachPortGetInvalidationCallBack(CFMachPortRef port); +CF_EXPORT void CFMachPortSetInvalidationCallBack(CFMachPortRef port, CFMachPortInvalidationCallBack callout); + +CF_EXPORT CFRunLoopSourceRef CFMachPortCreateRunLoopSource(CFAllocatorRef allocator, CFMachPortRef port, CFIndex order); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFMACHPORT__ */ + diff --git a/include/CoreFoundation/CFMessagePort.h b/include/CoreFoundation/CFMessagePort.h new file mode 100644 index 0000000..a4aa040 --- /dev/null +++ b/include/CoreFoundation/CFMessagePort.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFMessagePort.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFMESSAGEPORT__) +#define __COREFOUNDATION_CFMESSAGEPORT__ 1 + +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMessagePort) __CFMessagePort * CFMessagePortRef; + +enum { + kCFMessagePortSuccess = 0, + kCFMessagePortSendTimeout = -1, + kCFMessagePortReceiveTimeout = -2, + kCFMessagePortIsInvalid = -3, + kCFMessagePortTransportError = -4, + kCFMessagePortBecameInvalidError = -5 +}; + +typedef struct { + CFIndex version; + void * info; + const void *(*retain)(const void *info); + void (*release)(const void *info); + CFStringRef (*copyDescription)(const void *info); +} CFMessagePortContext; + +typedef CFDataRef (*CFMessagePortCallBack)(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info); +/* 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. */ +typedef void (*CFMessagePortInvalidationCallBack)(CFMessagePortRef ms, void *info); + +CF_EXPORT CFTypeID CFMessagePortGetTypeID(void); + +CF_EXPORT CFMessagePortRef CFMessagePortCreateLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo); +CF_EXPORT CFMessagePortRef CFMessagePortCreateRemote(CFAllocatorRef allocator, CFStringRef name); + +CF_EXPORT Boolean CFMessagePortIsRemote(CFMessagePortRef ms); +CF_EXPORT CFStringRef CFMessagePortGetName(CFMessagePortRef ms); +CF_EXPORT Boolean CFMessagePortSetName(CFMessagePortRef ms, CFStringRef newName); +CF_EXPORT void CFMessagePortGetContext(CFMessagePortRef ms, CFMessagePortContext *context); +CF_EXPORT void CFMessagePortInvalidate(CFMessagePortRef ms); +CF_EXPORT Boolean CFMessagePortIsValid(CFMessagePortRef ms); +CF_EXPORT CFMessagePortInvalidationCallBack CFMessagePortGetInvalidationCallBack(CFMessagePortRef ms); +CF_EXPORT void CFMessagePortSetInvalidationCallBack(CFMessagePortRef ms, CFMessagePortInvalidationCallBack callout); + +/* NULL replyMode argument means no return value expected, dont wait for it */ +CF_EXPORT SInt32 CFMessagePortSendRequest(CFMessagePortRef remote, SInt32 msgid, CFDataRef data, CFTimeInterval sendTimeout, CFTimeInterval rcvTimeout, CFStringRef replyMode, CFDataRef *returnData); + +CF_EXPORT CFRunLoopSourceRef CFMessagePortCreateRunLoopSource(CFAllocatorRef allocator, CFMessagePortRef local, CFIndex order); + +CF_EXPORT void CFMessagePortSetDispatchQueue(CFMessagePortRef ms, dispatch_queue_t queue) CF_AVAILABLE(10_6, 4_0); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFMESSAGEPORT__ */ + diff --git a/include/CoreFoundation/CFNotificationCenter.h b/include/CoreFoundation/CFNotificationCenter.h new file mode 100644 index 0000000..28ccabd --- /dev/null +++ b/include/CoreFoundation/CFNotificationCenter.h @@ -0,0 +1,37 @@ +#if !defined(__COREFOUNDATION_CFNOTIFICATIONCENTER__) +#define __COREFOUNDATION_CFNOTIFICATIONCENTER__ 1 + +#include +#include + +CF_EXTERN_C_BEGIN + +typedef struct __CFNotificationCenter * CFNotificationCenterRef; + +typedef void (*CFNotificationCallback)(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo); + +typedef CF_ENUM(CFIndex, CFNotificationSuspensionBehavior) { + CFNotificationSuspensionBehaviorDrop = 1, + CFNotificationSuspensionBehaviorCoalesce = 2, + CFNotificationSuspensionBehaviorHold = 3, + CFNotificationSuspensionBehaviorDeliverImmediately = 4 +}; + +enum { + kCFNotificationDeliverImmediately = (1UL << 0), + kCFNotificationPostToAllSessions = (1UL << 1) +}; + +CF_EXPORT CFTypeID CFNotificationCenterGetTypeID(void); +CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetLocalCenter(void); +CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetDarwinNotifyCenter(void); +CF_EXPORT void CFNotificationCenterAddObserver(CFNotificationCenterRef center, const void *observer, CFNotificationCallback callBack, CFStringRef name, const void *object, CFNotificationSuspensionBehavior suspensionBehavior); +CF_EXPORT void CFNotificationCenterRemoveObserver(CFNotificationCenterRef center, const void *observer, CFStringRef name, const void *object); +CF_EXPORT void CFNotificationCenterRemoveEveryObserver(CFNotificationCenterRef center, const void *observer); +CF_EXPORT void CFNotificationCenterPostNotification(CFNotificationCenterRef center, CFStringRef name, const void *object, CFDictionaryRef userInfo, Boolean deliverImmediately); +CF_EXPORT void CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterRef center, CFStringRef name, const void *object, CFDictionaryRef userInfo, CFOptionFlags options); + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFNOTIFICATIONCENTER__ */ + diff --git a/include/CoreFoundation/CFNumber.h b/include/CoreFoundation/CFNumber.h new file mode 100644 index 0000000..e975113 --- /dev/null +++ b/include/CoreFoundation/CFNumber.h @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFNumber.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFNUMBER__) +#define __COREFOUNDATION_CFNUMBER__ 1 + +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef const struct CF_BRIDGED_TYPE(NSNumber) __CFBoolean * CFBooleanRef; + +CF_EXPORT +const CFBooleanRef kCFBooleanTrue; +CF_EXPORT +const CFBooleanRef kCFBooleanFalse; + +CF_EXPORT +CFTypeID CFBooleanGetTypeID(void); + +CF_EXPORT +Boolean CFBooleanGetValue(CFBooleanRef boolean); + +typedef CF_ENUM(CFIndex, CFNumberType) { + /* Fixed-width types */ + kCFNumberSInt8Type = 1, + kCFNumberSInt16Type = 2, + kCFNumberSInt32Type = 3, + kCFNumberSInt64Type = 4, + kCFNumberFloat32Type = 5, + kCFNumberFloat64Type = 6, /* 64-bit IEEE 754 */ + /* Basic C types */ + kCFNumberCharType = 7, + kCFNumberShortType = 8, + kCFNumberIntType = 9, + kCFNumberLongType = 10, + kCFNumberLongLongType = 11, + kCFNumberFloatType = 12, + kCFNumberDoubleType = 13, + /* Other */ + kCFNumberCFIndexType = 14, + kCFNumberNSIntegerType CF_ENUM_AVAILABLE(10_5, 2_0) = 15, + kCFNumberCGFloatType CF_ENUM_AVAILABLE(10_5, 2_0) = 16, + kCFNumberMaxType = 16 +}; + +typedef const struct CF_BRIDGED_TYPE(NSNumber) __CFNumber * CFNumberRef; + +CF_EXPORT +const CFNumberRef kCFNumberPositiveInfinity; +CF_EXPORT +const CFNumberRef kCFNumberNegativeInfinity; +CF_EXPORT +const CFNumberRef kCFNumberNaN; + +CF_EXPORT +CFTypeID CFNumberGetTypeID(void); + +/* + Creates a CFNumber with the given value. The type of number pointed + to by the valuePtr is specified by type. If type is a floating point + type and the value represents one of the infinities or NaN, the + well-defined CFNumber for that value is returned. If either of + valuePtr or type is an invalid value, the result is undefined. +*/ +CF_EXPORT +CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr); + +/* + Returns the storage format of the CFNumber's value. Note that + this is not necessarily the type provided in CFNumberCreate(). +*/ +CF_EXPORT +CFNumberType CFNumberGetType(CFNumberRef number); + +/* + Returns the size in bytes of the type of the number. +*/ +CF_EXPORT +CFIndex CFNumberGetByteSize(CFNumberRef number); + +/* + Returns true if the type of the CFNumber's value is one of + the defined floating point types. +*/ +CF_EXPORT +Boolean CFNumberIsFloatType(CFNumberRef number); + +/* + Copies the CFNumber's value into the space pointed to by + valuePtr, as the specified type. If conversion needs to take + place, the conversion rules follow human expectation and not + C's promotion and truncation rules. If the conversion is + lossy, or the value is out of range, false is returned. Best + attempt at conversion will still be in *valuePtr. +*/ +CF_EXPORT +Boolean CFNumberGetValue(CFNumberRef number, CFNumberType theType, void *valuePtr); + +/* + Compares the two CFNumber instances. If conversion of the + types of the values is needed, the conversion and comparison + follow human expectations and not C's promotion and comparison + rules. Negative zero compares less than positive zero. + Positive infinity compares greater than everything except + itself, to which it compares equal. Negative infinity compares + less than everything except itself, to which it compares equal. + Unlike standard practice, if both numbers are NaN, then they + compare equal; if only one of the numbers is NaN, then the NaN + compares greater than the other number if it is negative, and + smaller than the other number if it is positive. (Note that in + CFEqual() with two CFNumbers, if either or both of the numbers + is NaN, true is returned.) +*/ +CF_EXPORT +CFComparisonResult CFNumberCompare(CFNumberRef number, CFNumberRef otherNumber, void *context); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFNUMBER__ */ + diff --git a/include/CoreFoundation/CFNumberFormatter.h b/include/CoreFoundation/CFNumberFormatter.h new file mode 100644 index 0000000..2c3a6e4 --- /dev/null +++ b/include/CoreFoundation/CFNumberFormatter.h @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFNumberFormatter.h + Copyright (c) 2003-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFNUMBERFORMATTER__) +#define __COREFOUNDATION_CFNUMBERFORMATTER__ 1 + +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct __CFNumberFormatter *CFNumberFormatterRef; + +// CFNumberFormatters are not thread-safe. Do not use one from multiple threads! + +CF_EXPORT +CFTypeID CFNumberFormatterGetTypeID(void); + +typedef CF_ENUM(CFIndex, CFNumberFormatterStyle) { // number format styles + kCFNumberFormatterNoStyle = 0, + kCFNumberFormatterDecimalStyle = 1, + kCFNumberFormatterCurrencyStyle = 2, + kCFNumberFormatterPercentStyle = 3, + kCFNumberFormatterScientificStyle = 4, + kCFNumberFormatterSpellOutStyle = 5 +}; + + +CF_EXPORT +CFNumberFormatterRef CFNumberFormatterCreate(CFAllocatorRef allocator, CFLocaleRef locale, CFNumberFormatterStyle style); + // Returns a CFNumberFormatter, localized to the given locale, which + // will format numbers to the given style. + +CF_EXPORT +CFLocaleRef CFNumberFormatterGetLocale(CFNumberFormatterRef formatter); + +CF_EXPORT +CFNumberFormatterStyle CFNumberFormatterGetStyle(CFNumberFormatterRef formatter); + // Get the properties with which the number formatter was created. + +CF_EXPORT +CFStringRef CFNumberFormatterGetFormat(CFNumberFormatterRef formatter); + +CF_EXPORT +void CFNumberFormatterSetFormat(CFNumberFormatterRef formatter, CFStringRef formatString); + // Set the format description string of the number formatter. This + // overrides the style settings. The format of the format string + // is as defined by the ICU library, and is similar to that found + // in Microsoft Excel and NSNumberFormatter. + // The number formatter starts with a default format string defined + // by the style argument with which it was created. + + +CF_EXPORT +CFStringRef CFNumberFormatterCreateStringWithNumber(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFNumberRef number); + +CF_EXPORT +CFStringRef CFNumberFormatterCreateStringWithValue(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFNumberType numberType, const void *valuePtr); + // Create a string representation of the given number or value + // using the current state of the number formatter. + + +typedef CF_OPTIONS(CFOptionFlags, CFNumberFormatterOptionFlags) { + kCFNumberFormatterParseIntegersOnly = 1 /* only parse integers */ +}; + +CF_EXPORT +CFNumberRef CFNumberFormatterCreateNumberFromString(CFAllocatorRef allocator, CFNumberFormatterRef formatter, CFStringRef string, CFRange *rangep, CFOptionFlags options); + +CF_EXPORT +Boolean CFNumberFormatterGetValueFromString(CFNumberFormatterRef formatter, CFStringRef string, CFRange *rangep, CFNumberType numberType, void *valuePtr); + // Parse a string representation of a number using the current state + // of the number formatter. The range parameter specifies the range + // of the string in which the parsing should occur in input, and on + // output indicates the extent that was used; this parameter can + // be NULL, in which case the whole string may be used. The + // return value indicates whether some number was computed and + // (if valuePtr is not NULL) stored at the location specified by + // valuePtr. The numberType indicates the type of value pointed + // to by valuePtr. + + +CF_EXPORT +void CFNumberFormatterSetProperty(CFNumberFormatterRef formatter, CFStringRef key, CFTypeRef value); + +CF_EXPORT +CFTypeRef CFNumberFormatterCopyProperty(CFNumberFormatterRef formatter, CFStringRef key); + // Set and get various properties of the number formatter, the set of + // which may be expanded in the future. + +CF_EXPORT const CFStringRef kCFNumberFormatterCurrencyCode; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterDecimalSeparator; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterCurrencyDecimalSeparator; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterAlwaysShowDecimalSeparator; // CFBoolean +CF_EXPORT const CFStringRef kCFNumberFormatterGroupingSeparator; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterUseGroupingSeparator; // CFBoolean +CF_EXPORT const CFStringRef kCFNumberFormatterPercentSymbol; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterZeroSymbol; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterNaNSymbol; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterInfinitySymbol; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterMinusSign; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterPlusSign; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterCurrencySymbol; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterExponentSymbol; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterMinIntegerDigits; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterMaxIntegerDigits; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterMinFractionDigits; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterMaxFractionDigits; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterGroupingSize; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterSecondaryGroupingSize; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterRoundingMode; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterRoundingIncrement; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterFormatWidth; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterPaddingPosition; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterPaddingCharacter; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterDefaultFormat; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterMultiplier; // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterPositivePrefix; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterPositiveSuffix; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterNegativePrefix; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterNegativeSuffix; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterPerMillSymbol; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterInternationalCurrencySymbol; // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterCurrencyGroupingSeparator CF_AVAILABLE(10_5, 2_0); // CFString +CF_EXPORT const CFStringRef kCFNumberFormatterIsLenient CF_AVAILABLE(10_5, 2_0); // CFBoolean +CF_EXPORT const CFStringRef kCFNumberFormatterUseSignificantDigits CF_AVAILABLE(10_5, 2_0); // CFBoolean +CF_EXPORT const CFStringRef kCFNumberFormatterMinSignificantDigits CF_AVAILABLE(10_5, 2_0); // CFNumber +CF_EXPORT const CFStringRef kCFNumberFormatterMaxSignificantDigits CF_AVAILABLE(10_5, 2_0); // CFNumber + +typedef CF_ENUM(CFIndex, CFNumberFormatterRoundingMode) { + kCFNumberFormatterRoundCeiling = 0, + kCFNumberFormatterRoundFloor = 1, + kCFNumberFormatterRoundDown = 2, + kCFNumberFormatterRoundUp = 3, + kCFNumberFormatterRoundHalfEven = 4, + kCFNumberFormatterRoundHalfDown = 5, + kCFNumberFormatterRoundHalfUp = 6 +}; + +typedef CF_ENUM(CFIndex, CFNumberFormatterPadPosition) { + kCFNumberFormatterPadBeforePrefix = 0, + kCFNumberFormatterPadAfterPrefix = 1, + kCFNumberFormatterPadBeforeSuffix = 2, + kCFNumberFormatterPadAfterSuffix = 3 +}; + + +CF_EXPORT +Boolean CFNumberFormatterGetDecimalInfoForCurrencyCode(CFStringRef currencyCode, int32_t *defaultFractionDigits, double *roundingIncrement); + // Returns the number of fraction digits that should be displayed, and + // the rounding increment (or 0.0 if no rounding is done by the currency) + // for the given currency. Returns false if the currency code is unknown + // or the information is not available. + // Not localized because these are properties of the currency. + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFNUMBERFORMATTER__ */ + diff --git a/include/CoreFoundation/CFPlugIn.h b/include/CoreFoundation/CFPlugIn.h new file mode 100644 index 0000000..96df296 --- /dev/null +++ b/include/CoreFoundation/CFPlugIn.h @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFPlugIn.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFPLUGIN__) +#define __COREFOUNDATION_CFPLUGIN__ 1 + +#if !defined(COREFOUNDATION_CFPLUGINCOM_SEPARATE) +#define COREFOUNDATION_CFPLUGINCOM_SEPARATE 1 +#endif + +#include +#include +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +/* ================ Standard Info.plist keys for plugIns ================ */ + +CF_EXPORT const CFStringRef kCFPlugInDynamicRegistrationKey; +CF_EXPORT const CFStringRef kCFPlugInDynamicRegisterFunctionKey; +CF_EXPORT const CFStringRef kCFPlugInUnloadFunctionKey; +CF_EXPORT const CFStringRef kCFPlugInFactoriesKey; +CF_EXPORT const CFStringRef kCFPlugInTypesKey; + +/* ================= Function prototypes for various callbacks ================= */ +/* Function types that plugIn authors can implement for various purposes. */ + +typedef void (*CFPlugInDynamicRegisterFunction)(CFPlugInRef plugIn); +typedef void (*CFPlugInUnloadFunction)(CFPlugInRef plugIn); +typedef void *(*CFPlugInFactoryFunction)(CFAllocatorRef allocator, CFUUIDRef typeUUID); + +/* ================= Creating PlugIns ================= */ + +CF_EXPORT CFTypeID CFPlugInGetTypeID(void); + +CF_EXPORT CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL); + /* Might return an existing instance with the ref-count bumped. */ + +CF_EXPORT CFBundleRef CFPlugInGetBundle(CFPlugInRef plugIn); + +/* ================= Controlling load on demand ================= */ +/* For plugIns. */ +/* PlugIns that do static registration are load on demand by default. */ +/* PlugIns that do dynamic registration are not load on demand by default. */ +/* A dynamic registration function can call CFPlugInSetLoadOnDemand(). */ + +CF_EXPORT void CFPlugInSetLoadOnDemand(CFPlugInRef plugIn, Boolean flag); + +CF_EXPORT Boolean CFPlugInIsLoadOnDemand(CFPlugInRef plugIn); + +/* ================= Finding factories and creating instances ================= */ +/* For plugIn hosts. */ +/* Functions for finding factories to create specific types and actually creating instances of a type. */ + +/* This function finds all the factories from any plugin for the given type. Returns an array that the caller must release. */ +CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInType(CFUUIDRef typeUUID) CF_RETURNS_RETAINED; + + +/* 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. */ +CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInTypeInPlugIn(CFUUIDRef typeUUID, CFPlugInRef plugIn) CF_RETURNS_RETAINED; + +/* This function returns the IUnknown interface for the new instance. */ +CF_EXPORT void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID); + +/* ================= Registering factories and types ================= */ +/* For plugIn writers who must dynamically register things. */ +/* Functions to register factory functions and to associate factories with types. */ + +CF_EXPORT Boolean CFPlugInRegisterFactoryFunction(CFUUIDRef factoryUUID, CFPlugInFactoryFunction func); + +CF_EXPORT Boolean CFPlugInRegisterFactoryFunctionByName(CFUUIDRef factoryUUID, CFPlugInRef plugIn, CFStringRef functionName); + +CF_EXPORT Boolean CFPlugInUnregisterFactory(CFUUIDRef factoryUUID); + +CF_EXPORT Boolean CFPlugInRegisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID); + +CF_EXPORT Boolean CFPlugInUnregisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID); + +/* ================= Registering instances ================= */ +/* 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. */ +/* 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. */ + +CF_EXPORT void CFPlugInAddInstanceForFactory(CFUUIDRef factoryID); + +CF_EXPORT void CFPlugInRemoveInstanceForFactory(CFUUIDRef factoryID); + + +/* Obsolete API */ + +typedef struct __CFPlugInInstance *CFPlugInInstanceRef; + +typedef Boolean (*CFPlugInInstanceGetInterfaceFunction)(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl); +typedef void (*CFPlugInInstanceDeallocateInstanceDataFunction)(void *instanceData); + +CF_EXPORT Boolean CFPlugInInstanceGetInterfaceFunctionTable(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl); + +/* This function returns a retained object on 10.8 or later. */ +CF_EXPORT CFStringRef CFPlugInInstanceGetFactoryName(CFPlugInInstanceRef instance) CF_RETURNS_RETAINED; + +CF_EXPORT void *CFPlugInInstanceGetInstanceData(CFPlugInInstanceRef instance); + +CF_EXPORT CFTypeID CFPlugInInstanceGetTypeID(void); + +CF_EXPORT CFPlugInInstanceRef CFPlugInInstanceCreateWithInstanceDataSize(CFAllocatorRef allocator, CFIndex instanceDataSize, CFPlugInInstanceDeallocateInstanceDataFunction deallocateInstanceFunction, CFStringRef factoryName, CFPlugInInstanceGetInterfaceFunction getInterfaceFunction); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#if !COREFOUNDATION_CFPLUGINCOM_SEPARATE +#include +#endif /* !COREFOUNDATION_CFPLUGINCOM_SEPARATE */ + +#endif /* ! __COREFOUNDATION_CFPLUGIN__ */ + diff --git a/include/CoreFoundation/CFPlugInCOM.h b/include/CoreFoundation/CFPlugInCOM.h new file mode 100644 index 0000000..9e2859f --- /dev/null +++ b/include/CoreFoundation/CFPlugInCOM.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFPlugInCOM.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFPLUGINCOM__) +#define __COREFOUNDATION_CFPLUGINCOM__ 1 + +#include + +CF_EXTERN_C_BEGIN + +/* ================= IUnknown definition (C struct) ================= */ + +/* All interface structs must have an IUnknownStruct at the beginning. */ +/* The _reserved field is part of the Microsoft COM binary standard on Macintosh. */ +/* You can declare new C struct interfaces by defining a new struct that includes "IUNKNOWN_C_GUTS;" before the first field of the struct. */ + +typedef SInt32 HRESULT; +typedef UInt32 ULONG; +typedef void *LPVOID; +typedef CFUUIDBytes REFIID; + +#define SUCCEEDED(Status) ((HRESULT)(Status) >= 0) +#define FAILED(Status) ((HRESULT)(Status)<0) + +/* Macros for more detailed HRESULT analysis */ +#define IS_ERROR(Status) ((unsigned long)(Status) >> 31 == SEVERITY_ERROR) +#define HRESULT_CODE(hr) ((hr) & 0xFFFF) +#define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff) +#define HRESULT_SEVERITY(hr) (((hr) >> 31) & 0x1) +#define SEVERITY_SUCCESS 0 +#define SEVERITY_ERROR 1 + +/* Creating an HRESULT from its component pieces */ +#define MAKE_HRESULT(sev,fac,code) ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) ) + +/* Pre-defined success HRESULTS */ +#define S_OK ((HRESULT)0x00000000L) +#define S_FALSE ((HRESULT)0x00000001L) + +/* Common error HRESULTS */ +#define E_UNEXPECTED ((HRESULT)0x8000FFFFL) +#define E_NOTIMPL ((HRESULT)0x80000001L) +#define E_OUTOFMEMORY ((HRESULT)0x80000002L) +#define E_INVALIDARG ((HRESULT)0x80000003L) +#define E_NOINTERFACE ((HRESULT)0x80000004L) +#define E_POINTER ((HRESULT)0x80000005L) +#define E_HANDLE ((HRESULT)0x80000006L) +#define E_ABORT ((HRESULT)0x80000007L) +#define E_FAIL ((HRESULT)0x80000008L) +#define E_ACCESSDENIED ((HRESULT)0x80000009L) + +/* This macro should be used when defining all interface functions (as it is for the IUnknown functions below). */ +#define STDMETHODCALLTYPE + +/* 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. */ +#define __RPC_FAR + +/* The IUnknown interface */ +#define IUnknownUUID CFUUIDGetConstantUUIDWithBytes(kCFAllocatorSystemDefault, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) + +#define IUNKNOWN_C_GUTS \ + void *_reserved; \ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(void *thisPointer, REFIID iid, LPVOID *ppv); \ + ULONG (STDMETHODCALLTYPE *AddRef)(void *thisPointer); \ + ULONG (STDMETHODCALLTYPE *Release)(void *thisPointer) + +typedef struct IUnknownVTbl { + IUNKNOWN_C_GUTS; +} IUnknownVTbl; + +CF_EXTERN_C_END + + +/* C++ specific stuff */ +#if defined(__cplusplus) +/* ================= IUnknown definition (C++ class) ================= */ + +/* 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) */ + +class IUnknown +#if defined(__MWERKS__) && TARGET_OS_WIN32 + : __comobject +#endif +{ + public: + virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) = 0; + virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0; + virtual ULONG STDMETHODCALLTYPE Release(void) = 0; +}; + +#endif /* __cplusplus */ + +#endif /* ! __COREFOUNDATION_CFPLUGINCOM__ */ + diff --git a/include/CoreFoundation/CFPlugIn_Factory.h b/include/CoreFoundation/CFPlugIn_Factory.h new file mode 100644 index 0000000..84f84be --- /dev/null +++ b/include/CoreFoundation/CFPlugIn_Factory.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFPlugIn_Factory.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFPLUGIN_FACTORY__) +#define __COREFOUNDATION_CFPLUGIN_FACTORY__ 1 + +#include "CFBundle_Internal.h" + +CF_EXTERN_C_BEGIN + +typedef struct __CFPFactory *_CFPFactoryRef; + +extern _CFPFactoryRef _CFPFactoryCreate(CFAllocatorRef allocator, CFUUIDRef factoryID, CFPlugInFactoryFunction func); +extern _CFPFactoryRef _CFPFactoryCreateByName(CFAllocatorRef allocator, CFUUIDRef factoryID, CFPlugInRef plugIn, CFStringRef funcName); + +extern _CFPFactoryRef _CFPFactoryFind(CFUUIDRef factoryID, Boolean enabled); + +extern CFUUIDRef _CFPFactoryCopyFactoryID(_CFPFactoryRef factory); +extern CFPlugInRef _CFPFactoryCopyPlugIn(_CFPFactoryRef factory); + +extern void *_CFPFactoryCreateInstance(CFAllocatorRef allocator, _CFPFactoryRef factory, CFUUIDRef typeID); +extern void _CFPFactoryDisable(_CFPFactoryRef factory); + +extern void _CFPFactoryFlushFunctionCache(_CFPFactoryRef factory); + +extern void _CFPFactoryAddType(_CFPFactoryRef factory, CFUUIDRef typeID); +extern void _CFPFactoryRemoveType(_CFPFactoryRef factory, CFUUIDRef typeID); + +extern Boolean _CFPFactorySupportsType(_CFPFactoryRef factory, CFUUIDRef typeID); +extern CFArrayRef _CFPFactoryFindCopyForType(CFUUIDRef typeID); + +/* 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. */ +extern void _CFPFactoryAddInstance(_CFPFactoryRef factory); +extern void _CFPFactoryRemoveInstance(_CFPFactoryRef factory); + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFPLUGIN_FACTORY__ */ + diff --git a/include/CoreFoundation/CFPreferences.h b/include/CoreFoundation/CFPreferences.h new file mode 100644 index 0000000..da7a686 --- /dev/null +++ b/include/CoreFoundation/CFPreferences.h @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFPreferences.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFPREFERENCES__) +#define __COREFOUNDATION_CFPREFERENCES__ 1 + +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +CF_EXPORT +const CFStringRef kCFPreferencesAnyApplication; +CF_EXPORT +const CFStringRef kCFPreferencesCurrentApplication; +CF_EXPORT +const CFStringRef kCFPreferencesAnyHost; +CF_EXPORT +const CFStringRef kCFPreferencesCurrentHost; +CF_EXPORT +const CFStringRef kCFPreferencesAnyUser; +CF_EXPORT +const CFStringRef kCFPreferencesCurrentUser; + +/* NOTE: All CFPropertyListRef values returned from + CFPreferences API should be assumed to be immutable. +*/ + +/* The "App" functions search the various sources of defaults that + apply to the given application, and should never be called with + kCFPreferencesAnyApplication - only kCFPreferencesCurrentApplication + or an application's ID (its bundle identifier). +*/ + +/* Searches the various sources of application defaults to find the +value for the given key. key must not be NULL. If a value is found, +it returns it; otherwise returns NULL. Caller must release the +returned value */ +CF_EXPORT +CFPropertyListRef CFPreferencesCopyAppValue(CFStringRef key, CFStringRef applicationID); + +/* Convenience to interpret a preferences value as a boolean directly. +Returns false if the key doesn't exist, or has an improper format; under +those conditions, keyExistsAndHasValidFormat (if non-NULL) is set to false */ +CF_EXPORT +Boolean CFPreferencesGetAppBooleanValue(CFStringRef key, CFStringRef applicationID, Boolean *keyExistsAndHasValidFormat); + +/* Convenience to interpret a preferences value as an integer directly. +Returns 0 if the key doesn't exist, or has an improper format; under +those conditions, keyExistsAndHasValidFormat (if non-NULL) is set to false */ +CF_EXPORT +CFIndex CFPreferencesGetAppIntegerValue(CFStringRef key, CFStringRef applicationID, Boolean *keyExistsAndHasValidFormat); + +/* Sets the given value for the given key in the "normal" place for +application preferences. key must not be NULL. If value is NULL, +key is removed instead. */ +CF_EXPORT +void CFPreferencesSetAppValue(CFStringRef key, CFPropertyListRef value, CFStringRef applicationID); + +/* Adds the preferences for the given suite to the app preferences for + the specified application. To write to the suite domain, use + CFPreferencesSetValue(), below, using the suiteName in place + of the appName */ +CF_EXPORT +void CFPreferencesAddSuitePreferencesToApp(CFStringRef applicationID, CFStringRef suiteID); + +CF_EXPORT +void CFPreferencesRemoveSuitePreferencesFromApp(CFStringRef applicationID, CFStringRef suiteID); + +/* Writes all changes in all sources of application defaults. +Returns success or failure. */ +CF_EXPORT +Boolean CFPreferencesAppSynchronize(CFStringRef applicationID); + +/* The primitive get mechanism; all arguments must be non-NULL +(use the constants above for common values). Only the exact +location specified by app-user-host is searched. The returned +CFType must be released by the caller when it is finished with it. */ +CF_EXPORT +CFPropertyListRef CFPreferencesCopyValue(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); + +/* Convenience to fetch multiple keys at once. Keys in +keysToFetch that are not present in the returned dictionary +are not present in the domain. If keysToFetch is NULL, all +keys are fetched. */ +CF_EXPORT +CFDictionaryRef CFPreferencesCopyMultiple(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); + +/* The primitive set function; all arguments except value must be +non-NULL. If value is NULL, the given key is removed */ +CF_EXPORT +void CFPreferencesSetValue(CFStringRef key, CFPropertyListRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); + +/* Convenience to set multiple values at once. Behavior is undefined +if a key is in both keysToSet and keysToRemove */ +CF_EXPORT +void CFPreferencesSetMultiple(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); + +CF_EXPORT +Boolean CFPreferencesSynchronize(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); + +/* Constructs and returns the list of the name of all applications +which have preferences in the scope of the given user and host. +The returned value must be released by the caller; neither argument +may be NULL. */ +CF_EXPORT +CFArrayRef CFPreferencesCopyApplicationList(CFStringRef userName, CFStringRef hostName) CF_DEPRECATED(10_0, 10_9, 2_0, 7_0); + +/* Constructs and returns the list of all keys set in the given +location. The returned value must be released by the caller; +all arguments must be non-NULL */ +CF_EXPORT +CFArrayRef CFPreferencesCopyKeyList(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName); + + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFPREFERENCES__ */ + diff --git a/include/CoreFoundation/CFPriv.h b/include/CoreFoundation/CFPriv.h new file mode 100644 index 0000000..72131bc --- /dev/null +++ b/include/CoreFoundation/CFPriv.h @@ -0,0 +1,660 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFPriv.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +/* + APPLE SPI: NOT TO BE USED OUTSIDE APPLE! +*/ + +#if !defined(__COREFOUNDATION_CFPRIV__) +#define __COREFOUNDATION_CFPRIV__ 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +#include +#include +#endif + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || TARGET_OS_WIN32 +#include +#include +#include +#endif + +CF_EXTERN_C_BEGIN + +CF_EXPORT intptr_t _CFDoOperation(intptr_t code, intptr_t subcode1, intptr_t subcode2); + +CF_EXPORT void _CFRuntimeSetCFMPresent(void *a); + +CF_EXPORT const char *_CFProcessPath(void); +CF_EXPORT const char **_CFGetProcessPath(void); +CF_EXPORT const char **_CFGetProgname(void); + + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) +CF_EXPORT void _CFRunLoopSetCurrent(CFRunLoopRef rl); +#endif + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +CF_EXPORT CFRunLoopRef CFRunLoopGetMain(void); +CF_EXPORT SInt32 CFRunLoopRunSpecific(CFRunLoopRef rl, CFStringRef modeName, CFTimeInterval seconds, Boolean returnAfterSourceHandled); + + +CF_EXPORT void _CFRunLoopStopMode(CFRunLoopRef rl, CFStringRef modeName); + +CF_EXPORT CFIndex CFMachPortGetQueuedMessageCount(CFMachPortRef mp); + +CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url); +#endif +CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url); +CF_EXPORT CFURLRef _CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc, CFPropertyListRef pListRepresentation); + +CF_EXPORT void CFPreferencesFlushCaches(void); + + + +#if TARGET_OS_WIN32 +CF_EXPORT Boolean _CFURLGetWideFileSystemRepresentation(CFURLRef url, Boolean resolveAgainstBase, wchar_t *buffer, CFIndex bufferLength); +#endif + +#if !__LP64__ +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +struct FSSpec; +CF_EXPORT +Boolean _CFGetFSSpecFromURL(CFAllocatorRef alloc, CFURLRef url, struct FSSpec *spec); + +CF_EXPORT +CFURLRef _CFCreateURLFromFSSpec(CFAllocatorRef alloc, const struct FSSpec *voidspec, Boolean isDirectory); +#endif +#endif + +typedef CF_ENUM(CFIndex, CFURLComponentDecomposition) { + kCFURLComponentDecompositionNonHierarchical, + kCFURLComponentDecompositionRFC1808, /* use this for RFC 1738 decompositions as well */ + kCFURLComponentDecompositionRFC2396 +}; + +typedef struct { + CFStringRef scheme; + CFStringRef schemeSpecific; +} CFURLComponentsNonHierarchical; + +typedef struct { + CFStringRef scheme; + CFStringRef user; + CFStringRef password; + CFStringRef host; + CFIndex port; /* kCFNotFound means ignore/omit */ + CFArrayRef pathComponents; + CFStringRef parameterString; + CFStringRef query; + CFStringRef fragment; + CFURLRef baseURL; +} CFURLComponentsRFC1808; + +typedef struct { + CFStringRef scheme; + + /* if the registered name form of the net location is used, userinfo is NULL, port is kCFNotFound, and host is the entire registered name. */ + CFStringRef userinfo; + CFStringRef host; + CFIndex port; + + CFArrayRef pathComponents; + CFStringRef query; + CFStringRef fragment; + CFURLRef baseURL; +} CFURLComponentsRFC2396; + +/* Fills components and returns TRUE if the URL can be decomposed according to decompositionType; FALSE (leaving components unchanged) otherwise. components should be a pointer to the CFURLComponents struct defined above that matches decompositionStyle */ +CF_EXPORT +Boolean _CFURLCopyComponents(CFURLRef url, CFURLComponentDecomposition decompositionType, void *components); + +/* Creates and returns the URL described by components; components should point to the CFURLComponents struct defined above that matches decompositionType. */ +CF_EXPORT +CFURLRef _CFURLCreateFromComponents(CFAllocatorRef alloc, CFURLComponentDecomposition decompositionType, const void *components); +#define CFURLCopyComponents _CFURLCopyComponents +#define CFURLCreateFromComponents _CFURLCreateFromComponents + + + +CF_EXPORT Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *buffer, CFIndex maxBufLen); + +/* If this is publicized, we might need to create a GetBytesPtr type function as well. */ +CF_EXPORT CFStringRef _CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat, CFAllocatorRef contentsDeallocator); + +/* These return NULL on MacOS 8 */ +// This one leaks the returned string in order to be thread-safe. +// CF cannot help you in this matter if you continue to use this SPI. +CF_EXPORT +CFStringRef CFGetUserName(void); + +CF_EXPORT +CFStringRef CFCopyUserName(void); + +CF_EXPORT +CFURLRef CFCopyHomeDirectoryURLForUser(CFStringRef uName); /* Pass NULL for the current user's home directory */ + + +/* + CFCopySearchPathForDirectoriesInDomains returns the various + standard system directories where apps, resources, etc get + installed. Because queries can return multiple directories, + you get back a CFArray (which you should free when done) of + CFURLs. The directories are returned in search path order; + that is, the first place to look is returned first. This API + may return directories that do not exist yet. If NSUserDomain + is included in a query, then the results will contain "~" to + refer to the user's directory. Specify expandTilde to expand + this to the current user's home. Some calls might return no + directories! + ??? On MacOS 8 this function currently returns an empty array. +*/ +typedef CF_ENUM(CFIndex, CFSearchPathDirectory) { + kCFApplicationDirectory = 1, /* supported applications (Applications) */ + kCFDemoApplicationDirectory, /* unsupported applications, demonstration versions (Demos) */ + kCFDeveloperApplicationDirectory, /* developer applications (Developer/Applications) */ + kCFAdminApplicationDirectory, /* system and network administration applications (Administration) */ + kCFLibraryDirectory, /* various user-visible documentation, support, and configuration files, resources (Library) */ + kCFDeveloperDirectory, /* developer resources (Developer) */ + kCFUserDirectory, /* user home directories (Users) */ + kCFDocumentationDirectory, /* documentation (Documentation) */ + kCFDocumentDirectory, /* documents (Library/Documents) */ + + kCFCoreServiceDirectory = 10, // location of CoreServices directory (System/Library/CoreServices) + kCFAutosavedInformationDirectory = 11, // location of autosaved documents (Documents/Autosaved) + kCFDesktopDirectory = 12, // location of user's desktop + kCFCachesDirectory = 13, // location of discardable cache files (Library/Caches) + kCFApplicationSupportDirectory = 14, // location of application support files (plug-ins, etc) (Library/Application Support) + kCFDownloadsDirectory = 15, // location of the user's "Downloads" directory + kCFInputMethodsDirectory = 16, // input methods (Library/Input Methods) + kCFMoviesDirectory = 17, // location of user's Movies directory (~/Movies) + kCFMusicDirectory = 18, // location of user's Music directory (~/Music) + kCFPicturesDirectory = 19, // location of user's Pictures directory (~/Pictures) + kCFPrinterDescriptionDirectory = 20, // location of system's PPDs directory (Library/Printers/PPDs) + kCFSharedPublicDirectory = 21, // location of user's Public sharing directory (~/Public) + kCFPreferencePanesDirectory = 22, // location of the PreferencePanes directory for use with System Preferences (Library/PreferencePanes) + + kCFAllApplicationsDirectory = 100, /* all directories where applications can occur (ie Applications, Demos, Administration, Developer/Applications) */ + kCFAllLibrariesDirectory = 101 /* all directories where resources can occur (Library, Developer) */ +}; + +typedef CF_OPTIONS(CFOptionFlags, CFSearchPathDomainMask) { + kCFUserDomainMask = 1, /* user's home directory --- place to install user's personal items (~) */ + kCFLocalDomainMask = 2, /* local to the current machine --- place to install items available to everyone on this machine (/Local) */ + kCFNetworkDomainMask = 4, /* publically available location in the local area network --- place to install items available on the network (/Network) */ + kCFSystemDomainMask = 8, /* provided by Apple, unmodifiable (/System) */ + kCFAllDomainsMask = 0x0ffff /* all domains: all of the above and more, future items */ +}; + +CF_EXPORT +CFArrayRef CFCopySearchPathForDirectoriesInDomains(CFSearchPathDirectory directory, CFSearchPathDomainMask domainMask, Boolean expandTilde); + + +/* Obsolete keys */ +CF_EXPORT const CFStringRef kCFFileURLExists; +CF_EXPORT const CFStringRef kCFFileURLPOSIXMode; +CF_EXPORT const CFStringRef kCFFileURLSize; +CF_EXPORT const CFStringRef kCFFileURLDirectoryContents; +CF_EXPORT const CFStringRef kCFFileURLLastModificationTime; +CF_EXPORT const CFStringRef kCFHTTPURLStatusCode; +CF_EXPORT const CFStringRef kCFHTTPURLStatusLine; + + +/* System Version file access */ +CF_EXPORT CFStringRef CFCopySystemVersionString(void); // Human-readable string containing both marketing and build version +CF_EXPORT CFDictionaryRef _CFCopySystemVersionDictionary(void); +CF_EXPORT CFDictionaryRef _CFCopyServerVersionDictionary(void); +CF_EXPORT const CFStringRef _kCFSystemVersionProductNameKey; +CF_EXPORT const CFStringRef _kCFSystemVersionProductCopyrightKey; +CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionKey; +CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionExtraKey; +CF_EXPORT const CFStringRef _kCFSystemVersionProductUserVisibleVersionKey; // For loginwindow; see 2987512 +CF_EXPORT const CFStringRef _kCFSystemVersionBuildVersionKey; +CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionStringKey; // Localized string for the string "Version" +CF_EXPORT const CFStringRef _kCFSystemVersionBuildStringKey; // Localized string for the string "Build" + + +CF_EXPORT void CFMergeSortArray(void *list, CFIndex count, CFIndex elementSize, CFComparatorFunction comparator, void *context); +CF_EXPORT void CFQSortArray(void *list, CFIndex count, CFIndex elementSize, CFComparatorFunction comparator, void *context); + +/* _CFExecutableLinkedOnOrAfter(releaseVersionName) will return YES if the current executable seems to be linked on or after the specified release. Example: If you specify CFSystemVersionPuma (10.1), you will get back true for executables linked on Puma or Jaguar(10.2), but false for those linked on Cheetah (10.0) or any of its software updates (10.0.x). You will also get back false for any app whose version info could not be figured out. + This function caches its results, so no need to cache at call sites. + + Note that for non-MACH this function always returns true. +*/ +typedef CF_ENUM(CFIndex, CFSystemVersion) { + CFSystemVersionCheetah = 0, /* 10.0 */ + CFSystemVersionPuma = 1, /* 10.1 */ + CFSystemVersionJaguar = 2, /* 10.2 */ + CFSystemVersionPanther = 3, /* 10.3 */ + CFSystemVersionTiger = 4, /* 10.4 */ + CFSystemVersionLeopard = 5, /* 10.5 */ + CFSystemVersionSnowLeopard = 6, /* 10.6 */ + CFSystemVersionLion = 7, /* 10.7 */ + CFSystemVersionMountainLion = 8, /* 10.8 */ + CFSystemVersionMax, /* This should bump up when new entries are added */ + +}; + +CF_EXPORT Boolean _CFExecutableLinkedOnOrAfter(CFSystemVersion version); + + +typedef CF_ENUM(CFIndex, CFStringCharacterClusterType) { + kCFStringGraphemeCluster = 1, /* Unicode Grapheme Cluster */ + kCFStringComposedCharacterCluster = 2, /* Compose all non-base (including spacing marks) */ + kCFStringCursorMovementCluster = 3, /* Cluster suitable for cursor movements */ + kCFStringBackwardDeletionCluster = 4 /* Cluster suitable for backward deletion */ +}; + +CF_EXPORT CFRange CFStringGetRangeOfCharacterClusterAtIndex(CFStringRef string, CFIndex charIndex, CFStringCharacterClusterType type); + +// Compatibility kCFCompare flags. Use the new public kCFCompareDiacriticInsensitive +enum { + kCFCompareDiacriticsInsensitive = 128 /* Use kCFCompareDiacriticInsensitive */ +}; + +/* kCFCompare flags planned to be publicized (Aki 10/20/2008 Does not work with kCFCompareForceOrdering/CFStringFold). see ) + */ +enum { + kCFCompareIgnoreNonAlphanumeric = (1UL << 16), // Ignores characters NOT in kCFCharacterSetAlphaNumeric +}; + + +/* CFStringEncoding SPI */ +/* When set, CF encoding conversion engine keeps ASCII compatibility. (i.e. ASCII backslash <-> Unicode backslash in MacJapanese */ +CF_EXPORT void _CFStringEncodingSetForceASCIICompatibility(Boolean flag); + +extern void __CFSetCharToUniCharFunc(Boolean (*func)(UInt32 flags, UInt8 ch, UniChar *unicodeChar)); +extern UniChar __CFCharToUniCharTable[256]; + + +#if defined(CF_INLINE) +CF_INLINE const UniChar *CFStringGetCharactersPtrFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange) { + if ((desiredRange.location < 0) || ((desiredRange.location + desiredRange.length) > buf->rangeToBuffer.length)) return NULL; + + if (buf->directUniCharBuffer) { + return buf->directUniCharBuffer + buf->rangeToBuffer.location + desiredRange.location; + } else { + if (desiredRange.length > __kCFStringInlineBufferLength) return NULL; + + if (((desiredRange.location + desiredRange.length) > buf->bufferedRangeEnd) || (desiredRange.location < buf->bufferedRangeStart)) { + buf->bufferedRangeStart = desiredRange.location; + buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength; + if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length; + CFIndex location = buf->rangeToBuffer.location + buf->bufferedRangeStart; + CFIndex length = buf->bufferedRangeEnd - buf->bufferedRangeStart; + if (buf->directCStringBuffer) { + UniChar *bufPtr = buf->buffer; + while (length--) *bufPtr++ = (UniChar)buf->directCStringBuffer[location++]; + } else { + CFStringGetCharacters(buf->theString, CFRangeMake(location, length), buf->buffer); + } + } + + return buf->buffer + (desiredRange.location - buf->bufferedRangeStart); + } +} + +CF_INLINE void CFStringGetCharactersFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange, UniChar *outBuf) { + if (buf->directUniCharBuffer) { + memmove(outBuf, buf->directUniCharBuffer + buf->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar)); + } else { + if ((desiredRange.location >= buf->bufferedRangeStart) && (desiredRange.location < buf->bufferedRangeEnd)) { + CFIndex bufLen = desiredRange.length; + + if (bufLen > (buf->bufferedRangeEnd - desiredRange.location)) bufLen = (buf->bufferedRangeEnd - desiredRange.location); + + memmove(outBuf, buf->buffer + (desiredRange.location - buf->bufferedRangeStart), bufLen * sizeof(UniChar)); + outBuf += bufLen; desiredRange.location += bufLen; desiredRange.length -= bufLen; + } else { + CFIndex desiredRangeMax = (desiredRange.location + desiredRange.length); + + if ((desiredRangeMax > buf->bufferedRangeStart) && (desiredRangeMax < buf->bufferedRangeEnd)) { + desiredRange.length = (buf->bufferedRangeStart - desiredRange.location); + memmove(outBuf + desiredRange.length, buf->buffer, (desiredRangeMax - buf->bufferedRangeStart) * sizeof(UniChar)); + } + } + + if (desiredRange.length > 0) { + CFIndex location = buf->rangeToBuffer.location + desiredRange.location; + CFIndex length = desiredRange.length; + if (buf->directCStringBuffer) { + UniChar *bufPtr = outBuf; + while (length--) *bufPtr++ = (UniChar)buf->directCStringBuffer[location++]; + } else { + CFStringGetCharacters(buf->theString, CFRangeMake(location, length), outBuf); + } + } + } +} + +#else +#define CFStringGetCharactersPtrFromInlineBuffer(buf, desiredRange) ((buf)->directUniCharBuffer ? (buf)->directUniCharBuffer + (buf)->rangeToBuffer.location + desiredRange.location : NULL) + +#define CFStringGetCharactersFromInlineBuffer(buf, desiredRange, outBuf) \ + if (buf->directUniCharBuffer) memmove(outBuf, (buf)->directUniCharBuffer + (buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar)); \ + else CFStringGetCharacters((buf)->theString, CFRangeMake((buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf); + +#endif /* CF_INLINE */ + + +#if defined(CF_INLINE) + +#ifndef __kCFStringAppendBufferLength + #define __kCFStringAppendBufferLength 1024 +#endif +typedef struct { + UniChar buffer[__kCFStringAppendBufferLength]; + CFIndex bufferIndex; + CFMutableStringRef theString; +} CFStringAppendBuffer; + + +// Initializes CFStringAppendBuffer with new mutable string. +CF_INLINE void CFStringInitAppendBuffer(CFAllocatorRef alloc, CFStringAppendBuffer *buf) +{ + buf->bufferIndex = 0; + buf->theString = CFStringCreateMutable(alloc, 0); +} + +// Appends the characters of a string to the CFStringAppendBuffer. +CF_INLINE void CFStringAppendStringToAppendBuffer(CFStringAppendBuffer *buf, CFStringRef appendedString) +{ + CFIndex numChars = CFStringGetLength(appendedString); + if ( numChars > __kCFStringAppendBufferLength ) { + if ( buf->bufferIndex ) { + CFStringAppendCharacters(buf->theString, buf->buffer, buf->bufferIndex); + buf->bufferIndex = 0; + } + CFStringAppend(buf->theString, appendedString); + } + else { + if ( (buf->bufferIndex + numChars) > __kCFStringAppendBufferLength ) { + CFStringAppendCharacters(buf->theString, buf->buffer, buf->bufferIndex); + buf->bufferIndex = 0; + } + CFStringGetCharacters(appendedString, CFRangeMake(0, numChars), &buf->buffer[buf->bufferIndex]); + buf->bufferIndex += numChars; + } +} + +// Appends a buffer of Unicode characters to the CFStringAppendBuffer. +CF_INLINE void CFStringAppendCharactersToAppendBuffer(CFStringAppendBuffer *buf, const UniChar *chars, CFIndex numChars) +{ + if ( numChars > __kCFStringAppendBufferLength ) { + if ( buf->bufferIndex ) { + CFStringAppendCharacters(buf->theString, buf->buffer, buf->bufferIndex); + buf->bufferIndex = 0; + } + CFStringAppendCharacters(buf->theString, chars, numChars); + } + else { + if ( (buf->bufferIndex + numChars) > __kCFStringAppendBufferLength ) { + CFStringAppendCharacters(buf->theString, buf->buffer, buf->bufferIndex); + buf->bufferIndex = 0; + } + memcpy(&buf->buffer[buf->bufferIndex], chars, numChars * sizeof(UniChar)); + buf->bufferIndex += numChars; + } +} + +// Returns a mutable string from the CFStringAppendBuffer. +CF_INLINE CFMutableStringRef CFStringCreateMutableWithAppendBuffer(CFStringAppendBuffer *buf) +{ + if ( buf->bufferIndex ) { + CFStringAppendCharacters(buf->theString, buf->buffer, buf->bufferIndex); + buf->bufferIndex = 0; + } + CFMutableStringRef result = buf->theString; + buf->theString = NULL; + return ( result ); +} + +#endif /* CF_INLINE */ + +/* + CFCharacterSetInlineBuffer related declarations + */ +/*! +@typedef CFCharacterSetInlineBuffer + @field cset The character set this inline buffer is initialized with. + The object is not retained by the structure. + @field flags The field is a bit mask that carries various settings. + @field rangeStart The beginning of the character range that contains all members. + It is guaranteed that there is no member below this value. + @field rangeLimit The end of the character range that contains all members. + It is guaranteed that there is no member above and equal to this value. + @field bitmap The bitmap data representing the membership of the Basic Multilingual Plane characters. + If NULL, all BMP characters inside the range are members of the character set. + */ +typedef struct { + CFCharacterSetRef cset; + uint32_t flags; + uint32_t rangeStart; + uint32_t rangeLimit; + const uint8_t *bitmap; +} CFCharacterSetInlineBuffer; + +// Bits for flags field +enum { + kCFCharacterSetIsCompactBitmap = (1UL << 0), + kCFCharacterSetNoBitmapAvailable = (1UL << 1), + kCFCharacterSetIsInverted = (1UL << 2) +}; + +/*! +@function CFCharacterSetInitInlineBuffer + Initializes buffer with cset. + @param cset The character set used to initialized the buffer. + If this parameter is not a valid CFCharacterSet, the behavior is undefined. + @param buffer The reference to the inline buffer to be initialized. + */ +CF_EXPORT +void CFCharacterSetInitInlineBuffer(CFCharacterSetRef cset, CFCharacterSetInlineBuffer *buffer); + +/*! +@function CFCharacterSetInlineBufferIsLongCharacterMember + Reports whether or not the UTF-32 character is in the character set. + @param buffer The reference to the inline buffer to be searched. + @param character The UTF-32 character for which to test against the + character set. + @result true, if the value is in the character set, otherwise false. + */ +#if defined(CF_INLINE) +CF_INLINE bool CFCharacterSetInlineBufferIsLongCharacterMember(const CFCharacterSetInlineBuffer *buffer, UTF32Char character) { + bool isInverted = ((0 == (buffer->flags & kCFCharacterSetIsInverted)) ? false : true); + + if ((character >= buffer->rangeStart) && (character < buffer->rangeLimit)) { + if ((character > 0xFFFF) || (0 != (buffer->flags & kCFCharacterSetNoBitmapAvailable))) return (CFCharacterSetIsLongCharacterMember(buffer->cset, character) != 0); + if (NULL == buffer->bitmap) { + if (0 == (buffer->flags & kCFCharacterSetIsCompactBitmap)) isInverted = !isInverted; + } else if (0 == (buffer->flags & kCFCharacterSetIsCompactBitmap)) { + if (buffer->bitmap[character >> 3] & (1UL << (character & 7))) isInverted = !isInverted; + } else { + uint8_t value = buffer->bitmap[character >> 8]; + + if (value == 0xFF) { + isInverted = !isInverted; + } else if (value > 0) { + const uint8_t *segment = buffer->bitmap + (256 + (32 * (value - 1))); + character &= 0xFF; + if (segment[character >> 3] & (1UL << (character % 8))) isInverted = !isInverted; + } + } + } + return isInverted; +} +#else /* CF_INLINE */ +#define CFCharacterSetInlineBufferIsLongCharacterMember(buffer, character) (CFCharacterSetIsLongCharacterMember(buffer->cset, character)) +#endif /* CF_INLINE */ + + +#if TARGET_OS_WIN32 +CF_EXPORT CFMutableStringRef _CFCreateApplicationRepositoryPath(CFAllocatorRef alloc, int nFolder); +#endif + +CF_EXPORT CFTypeRef _CFTryRetain(CFTypeRef cf); +CF_EXPORT Boolean _CFIsDeallocating(CFTypeRef cf); + +/* + CFLocaleGetLanguageRegionEncodingForLocaleIdentifier gets the appropriate language and region codes, + and the default legacy script code and encoding, for the specified locale (or language) string. + Returns false if CFLocale has no information about the given locale; otherwise may set + *langCode and/or *regCode to -1 if there is no appropriate legacy value for the locale. + This is a replacement for the CFBundle SPI CFBundleGetLocalizationInfoForLocalization (which was intended to be temporary and transitional); + this function is more up-to-date in its handling of locale strings, and is in CFLocale where this functionality should belong. Compared + to CFBundleGetLocalizationInfoForLocalization, this function does not spcially interpret a NULL localeIdentifier to mean use the single most + preferred localization in the current context (this function returns NO for a NULL localeIdentifier); and in this function + langCode, regCode, and scriptCode are all SInt16* (not SInt32* like the equivalent parameters in CFBundleGetLocalizationInfoForLocalization). +*/ +CF_EXPORT +Boolean CFLocaleGetLanguageRegionEncodingForLocaleIdentifier(CFStringRef localeIdentifier, LangCode *langCode, RegionCode *regCode, ScriptCode *scriptCode, CFStringEncoding *stringEncoding); + +#if TARGET_OS_WIN32 +CF_EXPORT CFMutableStringRef _CFCreateApplicationRepositoryPath(CFAllocatorRef alloc, int nFolder); +#endif + +#if TARGET_OS_WIN32 +#include + +#define CF_MESSAGE_PORT_CLONE_MESSAGE_ID -1209 +CF_EXPORT CFMessagePortRef CFMessagePortCreateUber(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo, Boolean isRemote); +CF_EXPORT void CFMessagePortSetCloneCallout(CFMessagePortRef ms, CFMessagePortCallBack cloneCallout); +#endif + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +#include + +CF_EXPORT CFMessagePortRef CFMessagePortCreatePerProcessLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo); +CF_EXPORT CFMessagePortRef CFMessagePortCreatePerProcessRemote(CFAllocatorRef allocator, CFStringRef name, CFIndex pid); + + +typedef CFDataRef (*CFMessagePortCallBackEx)(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info, void *trailer, uintptr_t); + +CF_EXPORT CFMessagePortRef _CFMessagePortCreateLocalEx(CFAllocatorRef allocator, CFStringRef name, Boolean perPID, uintptr_t unused, CFMessagePortCallBackEx callout2, CFMessagePortContext *context, Boolean *shouldFreeInfo); + +#endif + +#if TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX +#include +#else +// Avoid including the pthread header +#ifndef HAVE_STRUCT_TIMESPEC +#define HAVE_STRUCT_TIMESPEC 1 +struct timespec { long tv_sec; long tv_nsec; }; +#endif +#endif + +CF_INLINE CFAbsoluteTime _CFAbsoluteTimeFromFileTimeSpec(struct timespec ts) { + return (CFAbsoluteTime)((CFTimeInterval)ts.tv_sec - kCFAbsoluteTimeIntervalSince1970) + (1.0e-9 * (CFTimeInterval)ts.tv_nsec); +} + +CF_INLINE struct timespec _CFFileTimeSpecFromAbsoluteTime(CFAbsoluteTime at) { + struct timespec ts; + double sec = 0.0; + double frac = modf(at, &sec); + if (frac < 0.0) { + frac += 1.0; + sec -= 1.0; + } +#if TARGET_OS_WIN32 + ts.tv_sec = (long)(sec + kCFAbsoluteTimeIntervalSince1970); +#else + ts.tv_sec = (time_t)(sec + kCFAbsoluteTimeIntervalSince1970); +#endif + ts.tv_nsec = (long)(1000000000UL * frac + 0.5); + return ts; +} + +// The 'filtered' function below is preferred to this older one +CF_EXPORT bool _CFPropertyListCreateSingleValue(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFStringRef keyPath, CFPropertyListRef *value, CFErrorRef *error); + +// Returns a subset of the property list, only including the keyPaths in the CFSet. If the top level object is not a dictionary, you will get back an empty dictionary as the result. +CF_EXPORT bool _CFPropertyListCreateFiltered(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFSetRef keyPaths, CFPropertyListRef *value, CFErrorRef *error) CF_AVAILABLE(10_8, 6_0); + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || TARGET_OS_WIN32 + +// Returns a subset of a bundle's Info.plist. The keyPaths follow the same rules as above CFPropertyList function. This function takes platform and product keys into account. +typedef CF_OPTIONS(CFOptionFlags, _CFBundleFilteredPlistOptions) { + _CFBundleFilteredPlistMemoryMapped = 1 +} CF_ENUM_AVAILABLE(10_8, 6_0); + +CF_EXPORT CFPropertyListRef _CFBundleCreateFilteredInfoPlist(CFBundleRef bundle, CFSetRef keyPaths, _CFBundleFilteredPlistOptions options) CF_AVAILABLE(10_8, 6_0); +CF_EXPORT CFPropertyListRef _CFBundleCreateFilteredLocalizedInfoPlist(CFBundleRef bundle, CFSetRef keyPaths, CFStringRef localizationName, _CFBundleFilteredPlistOptions options) CF_AVAILABLE(10_8, 6_0); +#endif + +#if TARGET_OS_WIN32 +#include + +CF_EXPORT CFStringRef _CFGetWindowsAppleAppDataDirectory(void); +CF_EXPORT CFArrayRef _CFGetWindowsBinaryDirectories(void); +CF_EXPORT CFStringRef _CFGetWindowsAppleSystemLibraryDirectory(void); + +// If your Windows application does not use a CFRunLoop on the main thread (perhaps because it is reserved for handling UI events via Windows API), then call this function to make distributed notifications arrive using a different run loop. +CF_EXPORT void _CFNotificationCenterSetRunLoop(CFNotificationCenterRef nc, CFRunLoopRef rl); + +CF_EXPORT uint32_t /*DWORD*/ _CFRunLoopGetWindowsMessageQueueMask(CFRunLoopRef rl, CFStringRef modeName); +CF_EXPORT void _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopRef rl, uint32_t /*DWORD*/ mask, CFStringRef modeName); + +CF_EXPORT uint32_t /*DWORD*/ _CFRunLoopGetWindowsThreadID(CFRunLoopRef rl); + +typedef void (*CFWindowsMessageQueueHandler)(void); + +// Run Loop parameter must be the current thread's run loop for the next two functions; you cannot use another thread's run loop +CF_EXPORT CFWindowsMessageQueueHandler _CFRunLoopGetWindowsMessageQueueHandler(CFRunLoopRef rl, CFStringRef modeName); +CF_EXPORT void _CFRunLoopSetWindowsMessageQueueHandler(CFRunLoopRef rl, CFStringRef modeName, CFWindowsMessageQueueHandler func); + +#endif + + +CF_EXPORT CFArrayRef CFDateFormatterCreateDateFormatsFromTemplates(CFAllocatorRef allocator, CFArrayRef tmplates, CFOptionFlags options, CFLocaleRef locale); + +#if (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +// Available for internal use on embedded +CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void); +#endif + +CF_EXPORT const CFStringRef kCFNumberFormatterUsesCharacterDirection CF_AVAILABLE(10_9, 6_0); // CFBoolean +CF_EXPORT const CFStringRef kCFDateFormatterUsesCharacterDirection CF_AVAILABLE(10_9, 6_0); // CFBoolean + + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFPRIV__ */ + diff --git a/include/CoreFoundation/CFPropertyList.h b/include/CoreFoundation/CFPropertyList.h new file mode 100644 index 0000000..d07fa4a --- /dev/null +++ b/include/CoreFoundation/CFPropertyList.h @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFPropertyList.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFPROPERTYLIST__) +#define __COREFOUNDATION_CFPROPERTYLIST__ 1 + +#include +#include +#include +#include +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_EMBEDDED +#include +#endif + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef CF_OPTIONS(CFOptionFlags, CFPropertyListMutabilityOptions) { + kCFPropertyListImmutable = 0, + kCFPropertyListMutableContainers, + kCFPropertyListMutableContainersAndLeaves +}; + +CF_IMPLICIT_BRIDGING_DISABLED + +/* + Creates a property list object from its XML description; xmlData should + be the raw bytes of that description, possibly the contents of an XML + file. Returns NULL if the data cannot be parsed; if the parse fails + and errorString is non-NULL, a human-readable description of the failure + is returned in errorString. It is the caller's responsibility to release + either the returned object or the error string, whichever is applicable. + + This function is deprecated. See CFPropertyListCreateWithData() for a replacement. +*/ +CF_EXPORT +CFPropertyListRef CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags mutabilityOption, CFStringRef *errorString) CF_DEPRECATED(10_0, 10_10, 2_0, 8_0, "Use CFPropertyListCreateWithData instead."); + +/* + Returns the XML description of the given object; propertyList must + be one of the supported property list types, and (for composite types + like CFArray and CFDictionary) must not contain any elements that + are not themselves of a property list type. If a non-property list + type is encountered, NULL is returned. The returned data is + appropriate for writing out to an XML file. Note that a data, not a + string, is returned because the bytes contain in them a description + of the string encoding used. + + This function is deprecated. See CFPropertyListCreateData() for a replacement. +*/ +CF_EXPORT +CFDataRef CFPropertyListCreateXMLData(CFAllocatorRef allocator, CFPropertyListRef propertyList) CF_DEPRECATED(10_0, 10_10, 2_0, 8_0, "Use CFPropertyListCreateData instead."); + +CF_IMPLICIT_BRIDGING_ENABLED + +/* + Recursively creates a copy of the given property list (so nested arrays + and dictionaries are copied as well as the top-most container). The + resulting property list has the mutability characteristics determined + by mutabilityOption. +*/ +CF_EXPORT +CFPropertyListRef CFPropertyListCreateDeepCopy(CFAllocatorRef allocator, CFPropertyListRef propertyList, CFOptionFlags mutabilityOption); + +typedef CF_ENUM(CFIndex, CFPropertyListFormat) { + kCFPropertyListOpenStepFormat = 1, + kCFPropertyListXMLFormat_v1_0 = 100, + kCFPropertyListBinaryFormat_v1_0 = 200 +}; + +/* Returns true if the object graph rooted at plist is a valid property list + * graph -- that is, no cycles, containing only plist objects, and dictionary + * keys are strings. The debugging library version spits out some messages + * to be helpful. The plist structure which is to be allowed is given by + * the format parameter. */ +CF_EXPORT +Boolean CFPropertyListIsValid(CFPropertyListRef plist, CFPropertyListFormat format); + +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_EMBEDDED +CF_IMPLICIT_BRIDGING_DISABLED + +/* Writes the bytes of a plist serialization out to the stream. The + * stream must be opened and configured -- the function simply writes + * a bunch of bytes to the stream. The output plist format can be chosen. + * Leaves the stream open, but note that reading a plist expects the + * reading stream to end wherever the writing ended, so that the + * end of the plist data can be identified. Returns the number of bytes + * written, or 0 on error. Error messages are not currently localized, but + * may be in the future, so they are not suitable for comparison. + * + * This function is deprecated. See CFPropertyListWrite() for a replacement. */ +CF_EXPORT +CFIndex CFPropertyListWriteToStream(CFPropertyListRef propertyList, CFWriteStreamRef stream, CFPropertyListFormat format, CFStringRef *errorString) CF_DEPRECATED(10_2, 10_10, 2_0, 8_0, "Use CFPropertyListWrite instead."); + + +/* Same as current function CFPropertyListCreateFromXMLData() + * but takes a stream instead of data, and works on any plist file format. + * CFPropertyListCreateFromXMLData() also works on any plist file format. + * The stream must be open and configured -- the function simply reads a bunch + * of bytes from it starting at the current location in the stream, to the END + * of the stream, which is expected to be the end of the plist, or up to the + * number of bytes given by the length parameter if it is not 0. Error messages + * are not currently localized, but may be in the future, so they are not + * suitable for comparison. + * + * This function is deprecated. See CFPropertyListCreateWithStream() for a replacement. */ +CF_EXPORT +CFPropertyListRef CFPropertyListCreateFromStream(CFAllocatorRef allocator, CFReadStreamRef stream, CFIndex streamLength, CFOptionFlags mutabilityOption, CFPropertyListFormat *format, CFStringRef *errorString) CF_DEPRECATED(10_2, 10_10, 2_0, 8_0, "Use CFPropertyListCreateWithStream instead."); + +CF_IMPLICIT_BRIDGING_ENABLED +#endif + +CF_IMPLICIT_BRIDGING_DISABLED + +enum { + kCFPropertyListReadCorruptError = 3840, // Error parsing a property list + kCFPropertyListReadUnknownVersionError = 3841, // The version number in the property list is unknown + kCFPropertyListReadStreamError = 3842, // Stream error reading a property list + kCFPropertyListWriteStreamError = 3851, // Stream error writing a property list +} CF_ENUM_AVAILABLE(10_6, 4_0); + +/* Create a property list with a CFData input. If the format parameter is non-NULL, it will be set to the format of the data after parsing is complete. The options parameter is used to specify CFPropertyListMutabilityOptions. If an error occurs while parsing the data, the return value will be NULL. Additionally, if an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. If the parse succeeds, the returned value is a reference to the new property list. It is the responsibility of the caller to release this value. + */ +CF_EXPORT +CFPropertyListRef CFPropertyListCreateWithData(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags options, CFPropertyListFormat *format, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + +#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_EMBEDDED + +/* Create and return a property list with a CFReadStream input. If the format parameter is non-NULL, it will be set to the format of the data after parsing is complete. The options parameter is used to specify CFPropertyListMutabilityOptions. The streamLength parameter specifies the number of bytes to read from the stream. Set streamLength to 0 to read until the end of the stream is detected. If an error occurs while parsing the data, the return value will be NULL. Additionally, if an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. If the parse succeeds, the returned value is a reference to the new property list. It is the responsibility of the caller to release this value. + */ +CF_EXPORT +CFPropertyListRef CFPropertyListCreateWithStream(CFAllocatorRef allocator, CFReadStreamRef stream, CFIndex streamLength, CFOptionFlags options, CFPropertyListFormat *format, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + +/* Write the bytes of a serialized property list out to a stream. The stream must be opened and configured. The format of the property list can be chosen with the format parameter. The options parameter is currently unused and should be set to 0. The return value is the number of bytes written or 0 in the case of an error. If an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. + */ +CF_EXPORT +CFIndex CFPropertyListWrite(CFPropertyListRef propertyList, CFWriteStreamRef stream, CFPropertyListFormat format, CFOptionFlags options, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + +#endif + +/* Create a CFData with the bytes of a serialized property list. The format of the property list can be chosen with the format parameter. The options parameter is currently unused and should be set to 0. If an error occurs while parsing the data, the return value will be NULL. Additionally, if an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. If the conversion succeeds, the returned value is a reference to the created data. It is the responsibility of the caller to release this value. + */ +CF_EXPORT +CFDataRef CFPropertyListCreateData(CFAllocatorRef allocator, CFPropertyListRef propertyList, CFPropertyListFormat format, CFOptionFlags options, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + +CF_IMPLICIT_BRIDGING_ENABLED + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFPROPERTYLIST__ */ + diff --git a/include/CoreFoundation/CFRunLoop.h b/include/CoreFoundation/CFRunLoop.h new file mode 100644 index 0000000..967670c --- /dev/null +++ b/include/CoreFoundation/CFRunLoop.h @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFRunLoop.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFRUNLOOP__) +#define __COREFOUNDATION_CFRUNLOOP__ 1 + +#include +#include +#include +#include +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +#include +#endif + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct __CFRunLoop * CFRunLoopRef; + +typedef struct __CFRunLoopSource * CFRunLoopSourceRef; + +typedef struct __CFRunLoopObserver * CFRunLoopObserverRef; + +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSTimer) __CFRunLoopTimer * CFRunLoopTimerRef; + +/* Reasons for CFRunLoopRunInMode() to Return */ +enum { + kCFRunLoopRunFinished = 1, + kCFRunLoopRunStopped = 2, + kCFRunLoopRunTimedOut = 3, + kCFRunLoopRunHandledSource = 4 +}; + +/* Run Loop Observer Activities */ +typedef CF_OPTIONS(CFOptionFlags, CFRunLoopActivity) { + kCFRunLoopEntry = (1UL << 0), + kCFRunLoopBeforeTimers = (1UL << 1), + kCFRunLoopBeforeSources = (1UL << 2), + kCFRunLoopBeforeWaiting = (1UL << 5), + kCFRunLoopAfterWaiting = (1UL << 6), + kCFRunLoopExit = (1UL << 7), + kCFRunLoopAllActivities = 0x0FFFFFFFU +}; + +CF_EXPORT const CFStringRef kCFRunLoopDefaultMode; +CF_EXPORT const CFStringRef kCFRunLoopCommonModes; + +CF_EXPORT CFTypeID CFRunLoopGetTypeID(void); + +CF_EXPORT CFRunLoopRef CFRunLoopGetCurrent(void); +CF_EXPORT CFRunLoopRef CFRunLoopGetMain(void); + +CF_EXPORT CFStringRef CFRunLoopCopyCurrentMode(CFRunLoopRef rl); + +CF_EXPORT CFArrayRef CFRunLoopCopyAllModes(CFRunLoopRef rl); + +CF_EXPORT void CFRunLoopAddCommonMode(CFRunLoopRef rl, CFStringRef mode); + +CF_EXPORT CFAbsoluteTime CFRunLoopGetNextTimerFireDate(CFRunLoopRef rl, CFStringRef mode); + +CF_EXPORT void CFRunLoopRun(void); +CF_EXPORT SInt32 CFRunLoopRunInMode(CFStringRef mode, CFTimeInterval seconds, Boolean returnAfterSourceHandled); +CF_EXPORT Boolean CFRunLoopIsWaiting(CFRunLoopRef rl); +CF_EXPORT void CFRunLoopWakeUp(CFRunLoopRef rl); +CF_EXPORT void CFRunLoopStop(CFRunLoopRef rl); + +#if __BLOCKS__ +CF_EXPORT void CFRunLoopPerformBlock(CFRunLoopRef rl, CFTypeRef mode, void (^block)(void)) CF_AVAILABLE(10_6, 4_0); +#endif + +CF_EXPORT Boolean CFRunLoopContainsSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFStringRef mode); +CF_EXPORT void CFRunLoopAddSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFStringRef mode); +CF_EXPORT void CFRunLoopRemoveSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFStringRef mode); + +CF_EXPORT Boolean CFRunLoopContainsObserver(CFRunLoopRef rl, CFRunLoopObserverRef observer, CFStringRef mode); +CF_EXPORT void CFRunLoopAddObserver(CFRunLoopRef rl, CFRunLoopObserverRef observer, CFStringRef mode); +CF_EXPORT void CFRunLoopRemoveObserver(CFRunLoopRef rl, CFRunLoopObserverRef observer, CFStringRef mode); + +CF_EXPORT Boolean CFRunLoopContainsTimer(CFRunLoopRef rl, CFRunLoopTimerRef timer, CFStringRef mode); +CF_EXPORT void CFRunLoopAddTimer(CFRunLoopRef rl, CFRunLoopTimerRef timer, CFStringRef mode); +CF_EXPORT void CFRunLoopRemoveTimer(CFRunLoopRef rl, CFRunLoopTimerRef timer, CFStringRef mode); + +typedef struct { + CFIndex version; + void * info; + const void *(*retain)(const void *info); + void (*release)(const void *info); + CFStringRef (*copyDescription)(const void *info); + Boolean (*equal)(const void *info1, const void *info2); + CFHashCode (*hash)(const void *info); + void (*schedule)(void *info, CFRunLoopRef rl, CFStringRef mode); + void (*cancel)(void *info, CFRunLoopRef rl, CFStringRef mode); + void (*perform)(void *info); +} CFRunLoopSourceContext; + +typedef struct { + CFIndex version; + void * info; + const void *(*retain)(const void *info); + void (*release)(const void *info); + CFStringRef (*copyDescription)(const void *info); + Boolean (*equal)(const void *info1, const void *info2); + CFHashCode (*hash)(const void *info); +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) + mach_port_t (*getPort)(void *info); + void * (*perform)(void *msg, CFIndex size, CFAllocatorRef allocator, void *info); +#else + void * (*getPort)(void *info); + void (*perform)(void *info); +#endif +} CFRunLoopSourceContext1; + +CF_EXPORT CFTypeID CFRunLoopSourceGetTypeID(void); + +CF_EXPORT CFRunLoopSourceRef CFRunLoopSourceCreate(CFAllocatorRef allocator, CFIndex order, CFRunLoopSourceContext *context); + +CF_EXPORT CFIndex CFRunLoopSourceGetOrder(CFRunLoopSourceRef source); +CF_EXPORT void CFRunLoopSourceInvalidate(CFRunLoopSourceRef source); +CF_EXPORT Boolean CFRunLoopSourceIsValid(CFRunLoopSourceRef source); +CF_EXPORT void CFRunLoopSourceGetContext(CFRunLoopSourceRef source, CFRunLoopSourceContext *context); +CF_EXPORT void CFRunLoopSourceSignal(CFRunLoopSourceRef source); + +typedef struct { + CFIndex version; + void * info; + const void *(*retain)(const void *info); + void (*release)(const void *info); + CFStringRef (*copyDescription)(const void *info); +} CFRunLoopObserverContext; + +typedef void (*CFRunLoopObserverCallBack)(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info); + +CF_EXPORT CFTypeID CFRunLoopObserverGetTypeID(void); + +CF_EXPORT CFRunLoopObserverRef CFRunLoopObserverCreate(CFAllocatorRef allocator, CFOptionFlags activities, Boolean repeats, CFIndex order, CFRunLoopObserverCallBack callout, CFRunLoopObserverContext *context); +#if __BLOCKS__ +CF_EXPORT CFRunLoopObserverRef CFRunLoopObserverCreateWithHandler(CFAllocatorRef allocator, CFOptionFlags activities, Boolean repeats, CFIndex order, void (^block) (CFRunLoopObserverRef observer, CFRunLoopActivity activity)) CF_AVAILABLE(10_7, 5_0); +#endif + +CF_EXPORT CFOptionFlags CFRunLoopObserverGetActivities(CFRunLoopObserverRef observer); +CF_EXPORT Boolean CFRunLoopObserverDoesRepeat(CFRunLoopObserverRef observer); +CF_EXPORT CFIndex CFRunLoopObserverGetOrder(CFRunLoopObserverRef observer); +CF_EXPORT void CFRunLoopObserverInvalidate(CFRunLoopObserverRef observer); +CF_EXPORT Boolean CFRunLoopObserverIsValid(CFRunLoopObserverRef observer); +CF_EXPORT void CFRunLoopObserverGetContext(CFRunLoopObserverRef observer, CFRunLoopObserverContext *context); + +typedef struct { + CFIndex version; + void * info; + const void *(*retain)(const void *info); + void (*release)(const void *info); + CFStringRef (*copyDescription)(const void *info); +} CFRunLoopTimerContext; + +typedef void (*CFRunLoopTimerCallBack)(CFRunLoopTimerRef timer, void *info); + +CF_EXPORT CFTypeID CFRunLoopTimerGetTypeID(void); + +CF_EXPORT CFRunLoopTimerRef CFRunLoopTimerCreate(CFAllocatorRef allocator, CFAbsoluteTime fireDate, CFTimeInterval interval, CFOptionFlags flags, CFIndex order, CFRunLoopTimerCallBack callout, CFRunLoopTimerContext *context); +#if __BLOCKS__ +CF_EXPORT CFRunLoopTimerRef CFRunLoopTimerCreateWithHandler(CFAllocatorRef allocator, CFAbsoluteTime fireDate, CFTimeInterval interval, CFOptionFlags flags, CFIndex order, void (^block) (CFRunLoopTimerRef timer)) CF_AVAILABLE(10_7, 5_0); +#endif + +CF_EXPORT CFAbsoluteTime CFRunLoopTimerGetNextFireDate(CFRunLoopTimerRef timer); +CF_EXPORT void CFRunLoopTimerSetNextFireDate(CFRunLoopTimerRef timer, CFAbsoluteTime fireDate); +CF_EXPORT CFTimeInterval CFRunLoopTimerGetInterval(CFRunLoopTimerRef timer); +CF_EXPORT Boolean CFRunLoopTimerDoesRepeat(CFRunLoopTimerRef timer); +CF_EXPORT CFIndex CFRunLoopTimerGetOrder(CFRunLoopTimerRef timer); +CF_EXPORT void CFRunLoopTimerInvalidate(CFRunLoopTimerRef timer); +CF_EXPORT Boolean CFRunLoopTimerIsValid(CFRunLoopTimerRef timer); +CF_EXPORT void CFRunLoopTimerGetContext(CFRunLoopTimerRef timer, CFRunLoopTimerContext *context); + +// Setting a tolerance for a timer allows it to fire later than the scheduled fire date, improving the ability of the system to optimize for increased power savings and responsiveness. The timer may fire at any time between its scheduled fire date and the scheduled fire date plus the tolerance. The timer will not fire before the scheduled fire date. For repeating timers, the next fire date is calculated from the original fire date regardless of tolerance applied at individual fire times, to avoid drift. The default value is zero, which means no additional tolerance is applied. The system reserves the right to apply a small amount of tolerance to certain timers regardless of the value of this property. +// As the user of the timer, you will have the best idea of what an appropriate tolerance for a timer may be. A general rule of thumb, though, is to set the tolerance to at least 10% of the interval, for a repeating timer. Even a small amount of tolerance will have a significant positive impact on the power usage of your application. The system may put a maximum value of the tolerance. +CF_EXPORT CFTimeInterval CFRunLoopTimerGetTolerance(CFRunLoopTimerRef timer) CF_AVAILABLE(10_9, 7_0); +CF_EXPORT void CFRunLoopTimerSetTolerance(CFRunLoopTimerRef timer, CFTimeInterval tolerance) CF_AVAILABLE(10_9, 7_0); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFRUNLOOP__ */ + diff --git a/include/CoreFoundation/CFRuntime.h b/include/CoreFoundation/CFRuntime.h new file mode 100644 index 0000000..1eacd63 --- /dev/null +++ b/include/CoreFoundation/CFRuntime.h @@ -0,0 +1,281 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFRuntime.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFRUNTIME__) +#define __COREFOUNDATION_CFRUNTIME__ 1 + +#include +#include +#include + +CF_EXTERN_C_BEGIN + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) + +// GC: until we link against ObjC must use indirect functions. Overridden in CFSetupFoundationBridging +CF_EXPORT bool kCFUseCollectableAllocator; +CF_EXPORT bool (*__CFObjCIsCollectable)(void *); + +CF_INLINE Boolean _CFAllocatorIsSystemDefault(CFAllocatorRef allocator) { + if (allocator == kCFAllocatorSystemDefault) return true; + if (NULL == allocator || kCFAllocatorDefault == allocator) { + return (kCFAllocatorSystemDefault == CFAllocatorGetDefault()); + } + return false; +} + +// is GC on? +#define CF_USING_COLLECTABLE_MEMORY (kCFUseCollectableAllocator) +// is GC on and is this the GC allocator? +#define CF_IS_COLLECTABLE_ALLOCATOR(allocator) (kCFUseCollectableAllocator && (NULL == (allocator) || kCFAllocatorSystemDefault == (allocator) || 0)) +// is this allocated by the collector? +#define CF_IS_COLLECTABLE(obj) (__CFObjCIsCollectable ? __CFObjCIsCollectable((void*)obj) : false) + +#else + +#define kCFUseCollectableAllocator 0 +#define __CFObjCIsCollectable 0 + +CF_INLINE Boolean _CFAllocatorIsSystemDefault(CFAllocatorRef allocator) { + if (allocator == kCFAllocatorSystemDefault) return true; + if (NULL == allocator || kCFAllocatorDefault == allocator) { + return (kCFAllocatorSystemDefault == CFAllocatorGetDefault()); + } + return false; +} + +#define CF_USING_COLLECTABLE_MEMORY 0 +#define CF_IS_COLLECTABLE_ALLOCATOR(allocator) 0 +#define CF_IS_COLLECTABLE(obj) 0 +#endif + +enum { + _kCFRuntimeNotATypeID = 0 +}; + +enum { // Version field constants + _kCFRuntimeScannedObject = (1UL << 0), + _kCFRuntimeResourcefulObject = (1UL << 2), // tells CFRuntime to make use of the reclaim field + _kCFRuntimeCustomRefCount = (1UL << 3), // tells CFRuntime to make use of the refcount field + _kCFRuntimeRequiresAlignment = (1UL << 4), // tells CFRuntime to make use of the requiredAlignment field +}; + +typedef struct __CFRuntimeClass { + CFIndex version; + const char *className; // must be a pure ASCII string, nul-terminated + void (*init)(CFTypeRef cf); + CFTypeRef (*copy)(CFAllocatorRef allocator, CFTypeRef cf); + void (*finalize)(CFTypeRef cf); + Boolean (*equal)(CFTypeRef cf1, CFTypeRef cf2); + CFHashCode (*hash)(CFTypeRef cf); + CFStringRef (*copyFormattingDesc)(CFTypeRef cf, CFDictionaryRef formatOptions); // return str with retain + CFStringRef (*copyDebugDesc)(CFTypeRef cf); // return str with retain + +#define CF_RECLAIM_AVAILABLE 1 + void (*reclaim)(CFTypeRef cf); // Or in _kCFRuntimeResourcefulObject in the .version to indicate this field should be used + +#define CF_REFCOUNT_AVAILABLE 1 + uint32_t (*refcount)(intptr_t op, CFTypeRef cf); // Or in _kCFRuntimeCustomRefCount in the .version to indicate this field should be used + // this field must be non-NULL when _kCFRuntimeCustomRefCount is in the .version field + // - if the callback is passed 1 in 'op' it should increment the 'cf's reference count and return 0 + // - if the callback is passed 0 in 'op' it should return the 'cf's reference count, up to 32 bits + // - if the callback is passed -1 in 'op' it should decrement the 'cf's reference count; if it is now zero, 'cf' should be cleaned up and deallocated (the finalize callback above will NOT be called unless the process is running under GC, and CF does not deallocate the memory for you; if running under GC, finalize should do the object tear-down and free the object memory); then return 0 + // remember to use saturation arithmetic logic and stop incrementing and decrementing when the ref count hits UINT32_MAX, or you will have a security bug + // remember that reference count incrementing/decrementing must be done thread-safely/atomically + // objects should be created/initialized with a custom ref-count of 1 by the class creation functions + // do not attempt to use any bits within the CFRuntimeBase for your reference count; store that in some additional field in your CF object + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#define CF_REQUIRED_ALIGNMENT_AVAILABLE 1 + uintptr_t requiredAlignment; // Or in _kCFRuntimeRequiresAlignment in the .version field to indicate this field should be used; the allocator to _CFRuntimeCreateInstance() will be ignored in this case; if this is less than the minimum alignment the system supports, you'll get higher alignment; if this is not an alignment the system supports (e.g., most systems will only support powers of two, or if it is too high), the result (consequences) will be up to CF or the system to decide + +} CFRuntimeClass; + +#define RADAR_5115468_FIXED 1 + +/* Note that CF runtime class registration and unregistration is not currently + * thread-safe, which should not currently be a problem, as long as unregistration + * is done only when valid to do so. + */ + +CF_EXPORT CFTypeID _CFRuntimeRegisterClass(const CFRuntimeClass * const cls); + /* Registers a new class with the CF runtime. Pass in a + * pointer to a CFRuntimeClass structure. The pointer is + * remembered by the CF runtime -- the structure is NOT + * copied. + * + * - version field must be zero currently. + * - className field points to a null-terminated C string + * containing only ASCII (0 - 127) characters; this field + * may NOT be NULL. + * - init field points to a function which classes can use to + * apply some generic initialization to instances as they + * are created; this function is called by both + * _CFRuntimeCreateInstance and _CFRuntimeInitInstance; if + * this field is NULL, no function is called; the instance + * has been initialized enough that the polymorphic funcs + * CFGetTypeID(), CFRetain(), CFRelease(), CFGetRetainCount(), + * and CFGetAllocator() are valid on it when the init + * function if any is called. + * - copy field should always be NULL. Generic copying of CF + * objects has never been defined (and is unlikely). + * - finalize field points to a function which destroys an + * instance when the retain count has fallen to zero; if + * this is NULL, finalization does nothing. Note that if + * the class-specific functions which create or initialize + * instances more fully decide that a half-initialized + * instance must be destroyed, the finalize function for + * that class has to be able to deal with half-initialized + * instances. The finalize function should NOT destroy the + * memory for the instance itself; that is done by the + * CF runtime after this finalize callout returns. + * - equal field points to an equality-testing function; this + * field may be NULL, in which case only pointer/reference + * equality is performed on instances of this class. + * Pointer equality is tested, and the type IDs are checked + * for equality, before this function is called (so, the + * two instances are not pointer-equal but are of the same + * class before this function is called). + * NOTE: the equal function must implement an immutable + * equality relation, satisfying the reflexive, symmetric, + * and transitive properties, and remains the same across + * time and immutable operations (that is, if equal(A,B) at + * some point, then later equal(A,B) provided neither + * A or B has been mutated). + * - hash field points to a hash-code-computing function for + * instances of this class; this field may be NULL in which + * case the pointer value of an instance is converted into + * a hash. + * NOTE: the hash function and equal function must satisfy + * the relationship "equal(A,B) implies hash(A) == hash(B)"; + * that is, if two instances are equal, their hash codes must + * be equal too. (However, the converse is not true!) + * - copyFormattingDesc field points to a function returning a + * CFStringRef with a human-readable description of the + * instance; if this is NULL, the type does not have special + * human-readable string-formats. + * - copyDebugDesc field points to a function returning a + * CFStringRef with a debugging description of the instance; + * if this is NULL, a simple description is generated. + * + * This function returns _kCFRuntimeNotATypeID on failure, or + * on success, returns the CFTypeID for the new class. This + * CFTypeID is what the class uses to allocate or initialize + * instances of the class. It is also returned from the + * conventional *GetTypeID() function, which returns the + * class's CFTypeID so that clients can compare the + * CFTypeID of instances with that of a class. + * + * The function to compute a human-readable string is very + * optional, and is really only interesting for classes, + * like strings or numbers, where it makes sense to format + * the instance using just its contents. + */ + +CF_EXPORT const CFRuntimeClass * _CFRuntimeGetClassWithTypeID(CFTypeID typeID); + /* Returns the pointer to the CFRuntimeClass which was + * assigned the specified CFTypeID. + */ + +CF_EXPORT void _CFRuntimeUnregisterClassWithTypeID(CFTypeID typeID); + /* Unregisters the class with the given type ID. It is + * undefined whether type IDs are reused or not (expect + * that they will be). + * + * Whether or not unregistering the class is a good idea or + * not is not CF's responsibility. In particular you must + * be quite sure all instances are gone, and there are no + * valid weak refs to such in other threads. + */ + +/* All CF "instances" start with this structure. Never refer to + * these fields directly -- they are for CF's use and may be added + * to or removed or change format without warning. Binary + * compatibility for uses of this struct is not guaranteed from + * release to release. + */ +typedef struct __CFRuntimeBase { + uintptr_t _cfisa; + uint8_t _cfinfo[4]; +#if __LP64__ + uint32_t _rc; +#endif +} CFRuntimeBase; + +#if __BIG_ENDIAN__ +#define INIT_CFRUNTIME_BASE(...) {0, {0, 0, 0, 0x80}} +#else +#define INIT_CFRUNTIME_BASE(...) {0, {0x80, 0, 0, 0}} +#endif + +CF_EXPORT CFTypeRef _CFRuntimeCreateInstance(CFAllocatorRef allocator, CFTypeID typeID, CFIndex extraBytes, unsigned char *category); + /* Creates a new CF instance of the class specified by the + * given CFTypeID, using the given allocator, and returns it. + * If the allocator returns NULL, this function returns NULL. + * A CFRuntimeBase structure is initialized at the beginning + * of the returned instance. extraBytes is the additional + * number of bytes to allocate for the instance (BEYOND that + * needed for the CFRuntimeBase). If the specified CFTypeID + * is unknown to the CF runtime, this function returns NULL. + * No part of the new memory other than base header is + * initialized (the extra bytes are not zeroed, for example). + * All instances created with this function must be destroyed + * only through use of the CFRelease() function -- instances + * must not be destroyed by using CFAllocatorDeallocate() + * directly, even in the initialization or creation functions + * of a class. Pass NULL for the category parameter. + */ + +CF_EXPORT void _CFRuntimeSetInstanceTypeID(CFTypeRef cf, CFTypeID typeID); + /* This function changes the typeID of the given instance. + * If the specified CFTypeID is unknown to the CF runtime, + * this function does nothing. This function CANNOT be used + * to initialize an instance. It is for advanced usages such + * as faulting. You cannot change the CFTypeID of an object + * of a _kCFRuntimeCustomRefCount class, or to a + * _kCFRuntimeCustomRefCount class. + */ + +CF_EXPORT void _CFRuntimeInitStaticInstance(void *memory, CFTypeID typeID); + /* This function initializes a memory block to be a constant + * (unreleaseable) CF object of the given typeID. + * If the specified CFTypeID is unknown to the CF runtime, + * this function does nothing. The memory block should + * be a chunk of in-binary writeable static memory, and at + * least as large as sizeof(CFRuntimeBase) on the platform + * the code is being compiled for. The init function of the + * CFRuntimeClass is invoked on the memory as well, if the + * class has one. Static instances cannot be initialized to + * _kCFRuntimeCustomRefCount classes. + */ +#define CF_HAS_INIT_STATIC_INSTANCE 1 + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFRUNTIME__ */ + diff --git a/include/CoreFoundation/CFSet.h b/include/CoreFoundation/CFSet.h new file mode 100644 index 0000000..e555997 --- /dev/null +++ b/include/CoreFoundation/CFSet.h @@ -0,0 +1,509 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFSet.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ +/*! + @header CFSet + CFSet implements a container which stores unique values. +*/ + +#if !defined(__COREFOUNDATION_CFSET__) +#define __COREFOUNDATION_CFSET__ 1 + +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +/*! + @typedef CFSetRetainCallBack + Type of the callback function used by CFSets for retaining values. + @param allocator The allocator of the CFSet. + @param value The value to retain. + @result The value to store in the set, which is usually the value + parameter passed to this callback, but may be a different + value if a different value should be stored in the set. +*/ +typedef const void * (*CFSetRetainCallBack)(CFAllocatorRef allocator, const void *value); + +/*! + @typedef CFSetReleaseCallBack + Type of the callback function used by CFSets for releasing a retain on values. + @param allocator The allocator of the CFSet. + @param value The value to release. +*/ +typedef void (*CFSetReleaseCallBack)(CFAllocatorRef allocator, const void *value); + +/*! + @typedef CFSetCopyDescriptionCallBack + Type of the callback function used by CFSets for describing values. + @param value The value to describe. + @result A description of the specified value. +*/ +typedef CFStringRef (*CFSetCopyDescriptionCallBack)(const void *value); + +/*! + @typedef CFSetEqualCallBack + Type of the callback function used by CFSets for comparing values. + @param value1 The first value to compare. + @param value2 The second value to compare. + @result True if the values are equal, otherwise false. +*/ +typedef Boolean (*CFSetEqualCallBack)(const void *value1, const void *value2); + +/*! + @typedef CFSetHashCallBack + Type of the callback function used by CFSets for hashing values. + @param value The value to hash. + @result The hash of the value. +*/ +typedef CFHashCode (*CFSetHashCallBack)(const void *value); + +/*! + @typedef CFSetCallBacks + Structure containing the callbacks of a CFSet. + @field version The version number of the structure type being passed + in as a parameter to the CFSet creation functions. This + structure is version 0. + @field retain The callback used to add a retain for the set on + values as they are put into the set. This callback returns + the value to store in the set, which is usually the value + parameter passed to this callback, but may be a different + value if a different value should be stored in the set. + The set's allocator is passed as the first argument. + @field release The callback used to remove a retain previously added + for the set from values as they are removed from the + set. The set's allocator is passed as the first + argument. + @field copyDescription The callback used to create a descriptive + string representation of each value in the set. This is + used by the CFCopyDescription() function. + @field equal The callback used to compare values in the set for + equality for some operations. + @field hash The callback used to compare values in the set for + uniqueness for some operations. +*/ +typedef struct { + CFIndex version; + CFSetRetainCallBack retain; + CFSetReleaseCallBack release; + CFSetCopyDescriptionCallBack copyDescription; + CFSetEqualCallBack equal; + CFSetHashCallBack hash; +} CFSetCallBacks; + +/*! + @constant kCFTypeSetCallBacks + Predefined CFSetCallBacks structure containing a set of callbacks + appropriate for use when the values in a CFSet are all CFTypes. +*/ +CF_EXPORT +const CFSetCallBacks kCFTypeSetCallBacks; + +/*! + @constant kCFCopyStringSetCallBacks + Predefined CFSetCallBacks structure containing a set of callbacks + appropriate for use when the values in a CFSet should be copies + of a CFString. +*/ +CF_EXPORT +const CFSetCallBacks kCFCopyStringSetCallBacks; + +/*! + @typedef CFSetApplierFunction + Type of the callback function used by the apply functions of + CFSets. + @param value The current value from the set. + @param context The user-defined context parameter given to the apply + function. +*/ +typedef void (*CFSetApplierFunction)(const void *value, void *context); + +/*! + @typedef CFSetRef + This is the type of a reference to immutable CFSets. +*/ +typedef const struct CF_BRIDGED_TYPE(NSSet) __CFSet * CFSetRef; + +/*! + @typedef CFMutableSetRef + This is the type of a reference to mutable CFSets. +*/ +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSMutableSet) __CFSet * CFMutableSetRef; + +/*! + @function CFSetGetTypeID + Returns the type identifier of all CFSet instances. +*/ +CF_EXPORT +CFTypeID CFSetGetTypeID(void); + +/*! + @function CFSetCreate + Creates a new immutable set with the given values. + @param allocator The CFAllocator which should be used to allocate + memory for the set and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param values A C array of the pointer-sized values to be in the + set. This C array is not changed or freed by this function. + If this parameter is not a valid pointer to a C array of at + least numValues pointers, the behavior is undefined. + @param numValues The number of values to copy from the values C + array into the CFSet. This number will be the count of the + set. If this parameter is zero, negative, or greater than + the number of values actually in the values C array, the + behavior is undefined. + @param callBacks A C pointer to a CFSetCallBacks structure + initialized with the callbacks for the set to use on each + value in the set. A copy of the contents of the + callbacks structure is made, so that a pointer to a + structure on the stack can be passed in, or can be reused + for multiple set creations. If the version field of this + callbacks structure is not one of the defined ones for + CFSet, the behavior is undefined. The retain field may be + NULL, in which case the CFSet will do nothing to add a + retain to the contained values for the set. The release + field may be NULL, in which case the CFSet will do nothing + to remove the set's retain (if any) on the values when the + set is destroyed. If the copyDescription field is NULL, + the set will create a simple description for the value. If + the equal field is NULL, the set will use pointer equality + to test for equality of values. The hash field may be NULL, + in which case the CFSet will determine uniqueness by pointer + equality. This callbacks parameter + itself may be NULL, which is treated as if a valid structure + of version 0 with all fields NULL had been passed in. + Otherwise, if any of the fields are not valid pointers to + functions of the correct type, or this parameter is not a + valid pointer to a CFSetCallBacks callbacks structure, + the behavior is undefined. If any of the values put into the + set is not one understood by one of the callback functions + the behavior when that callback function is used is + undefined. + @result A reference to the new immutable CFSet. +*/ +CF_EXPORT +CFSetRef CFSetCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFSetCallBacks *callBacks); + +/*! + @function CFSetCreateCopy + Creates a new immutable set with the values from the given set. + @param allocator The CFAllocator which should be used to allocate + memory for the set and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param theSet The set which is to be copied. The values from the + set are copied as pointers into the new set (that is, + the values themselves are copied, not that which the values + point to, if anything). However, the values are also + retained by the new set. The count of the new set will + be the same as the copied set. The new set uses the same + callbacks as the set to be copied. If this parameter is + not a valid CFSet, the behavior is undefined. + @result A reference to the new immutable CFSet. +*/ +CF_EXPORT +CFSetRef CFSetCreateCopy(CFAllocatorRef allocator, CFSetRef theSet); + +/*! + @function CFSetCreateMutable + Creates a new empty mutable set. + @param allocator The CFAllocator which should be used to allocate + memory for the set and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param capacity A hint about the number of values that will be held + by the CFSet. Pass 0 for no hint. The implementation may + ignore this hint, or may use it to optimize various + operations. A set's actual capacity is only limited by + address space and available memory constraints). If this + parameter is negative, the behavior is undefined. + @param callBacks A C pointer to a CFSetCallBacks structure + initialized with the callbacks for the set to use on each + value in the set. A copy of the contents of the + callbacks structure is made, so that a pointer to a + structure on the stack can be passed in, or can be reused + for multiple set creations. If the version field of this + callbacks structure is not one of the defined ones for + CFSet, the behavior is undefined. The retain field may be + NULL, in which case the CFSet will do nothing to add a + retain to the contained values for the set. The release + field may be NULL, in which case the CFSet will do nothing + to remove the set's retain (if any) on the values when the + set is destroyed. If the copyDescription field is NULL, + the set will create a simple description for the value. If + the equal field is NULL, the set will use pointer equality + to test for equality of values. The hash field may be NULL, + in which case the CFSet will determine uniqueness by pointer + equality. This callbacks parameter + itself may be NULL, which is treated as if a valid structure + of version 0 with all fields NULL had been passed in. + Otherwise, if any of the fields are not valid pointers to + functions of the correct type, or this parameter is not a + valid pointer to a CFSetCallBacks callbacks structure, + the behavior is undefined. If any of the values put into the + set is not one understood by one of the callback functions + the behavior when that callback function is used is + undefined. + @result A reference to the new mutable CFSet. +*/ +CF_EXPORT +CFMutableSetRef CFSetCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFSetCallBacks *callBacks); + +/*! + @function CFSetCreateMutableCopy + Creates a new immutable set with the values from the given set. + @param allocator The CFAllocator which should be used to allocate + memory for the set and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param capacity A hint about the number of values that will be held + by the CFSet. Pass 0 for no hint. The implementation may + ignore this hint, or may use it to optimize various + operations. A set's actual capacity is only limited by + address space and available memory constraints). + This parameter must be greater than or equal + to the count of the set which is to be copied, or the + behavior is undefined. If this parameter is negative, the + behavior is undefined. + @param theSet The set which is to be copied. The values from the + set are copied as pointers into the new set (that is, + the values themselves are copied, not that which the values + point to, if anything). However, the values are also + retained by the new set. The count of the new set will + be the same as the copied set. The new set uses the same + callbacks as the set to be copied. If this parameter is + not a valid CFSet, the behavior is undefined. + @result A reference to the new mutable CFSet. +*/ +CF_EXPORT +CFMutableSetRef CFSetCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFSetRef theSet); + +/*! + @function CFSetGetCount + Returns the number of values currently in the set. + @param theSet The set to be queried. If this parameter is not a valid + CFSet, the behavior is undefined. + @result The number of values in the set. +*/ +CF_EXPORT +CFIndex CFSetGetCount(CFSetRef theSet); + +/*! + @function CFSetGetCountOfValue + Counts the number of times the given value occurs in the set. Since + sets by definition contain only one instance of a value, this function + is synonymous to CFSetContainsValue. + @param theSet The set to be searched. If this parameter is not a + valid CFSet, the behavior is undefined. + @param value The value for which to find matches in the set. The + equal() callback provided when the set was created is + used to compare. If the equal() callback was NULL, pointer + equality (in C, ==) is used. If value, or any of the values + in the set, are not understood by the equal() callback, + the behavior is undefined. + @result The number of times the given value occurs in the set. +*/ +CF_EXPORT +CFIndex CFSetGetCountOfValue(CFSetRef theSet, const void *value); + +/*! + @function CFSetContainsValue + Reports whether or not the value is in the set. + @param theSet The set to be searched. If this parameter is not a + valid CFSet, the behavior is undefined. + @param value The value for which to find matches in the set. The + equal() callback provided when the set was created is + used to compare. If the equal() callback was NULL, pointer + equality (in C, ==) is used. If value, or any of the values + in the set, are not understood by the equal() callback, + the behavior is undefined. + @result true, if the value is in the set, otherwise false. +*/ +CF_EXPORT +Boolean CFSetContainsValue(CFSetRef theSet, const void *value); + +/*! + @function CFSetGetValue + Retrieves a value in the set which hashes the same as the specified value. + @param theSet The set to be queried. If this parameter is not a + valid CFSet, the behavior is undefined. + @param value The value to retrieve. The equal() callback provided when + the set was created is used to compare. If the equal() callback + was NULL, pointer equality (in C, ==) is used. If a value, or + any of the values in the set, are not understood by the equal() + callback, the behavior is undefined. + @result The value in the set with the given hash. +*/ +CF_EXPORT +const void *CFSetGetValue(CFSetRef theSet, const void *value); + +/*! + @function CFSetGetValueIfPresent + Retrieves a value in the set which hashes the same as the specified value, + if present. + @param theSet The set to be queried. If this parameter is not a + valid CFSet, the behavior is undefined. + @param candidate This value is hashed and compared with values in the + set to determine which value to retrieve. The equal() callback provided when + the set was created is used to compare. If the equal() callback + was NULL, pointer equality (in C, ==) is used. If a value, or + any of the values in the set, are not understood by the equal() + callback, the behavior is undefined. + @param value A pointer to memory which should be filled with the + pointer-sized value if a matching value is found. If no + match is found, the contents of the storage pointed to by + this parameter are undefined. This parameter may be NULL, + in which case the value from the dictionary is not returned + (but the return value of this function still indicates + whether or not the value was present). + @result True if the value was present in the set, otherwise false. +*/ +CF_EXPORT +Boolean CFSetGetValueIfPresent(CFSetRef theSet, const void *candidate, const void **value); + +/*! + @function CFSetGetValues + Fills the buffer with values from the set. + @param theSet The set to be queried. If this parameter is not a + valid CFSet, the behavior is undefined. + @param values A C array of pointer-sized values to be filled with + values from the set. The values in the C array are ordered + in the same order in which they appear in the set. If this + parameter is not a valid pointer to a C array of at least + CFSetGetCount() pointers, the behavior is undefined. +*/ +CF_EXPORT +void CFSetGetValues(CFSetRef theSet, const void **values); + +/*! + @function CFSetApplyFunction + Calls a function once for each value in the set. + @param theSet The set to be operated upon. If this parameter is not + a valid CFSet, the behavior is undefined. + @param applier The callback function to call once for each value in + the given set. If this parameter is not a + pointer to a function of the correct prototype, the behavior + is undefined. If there are values in the set which the + applier function does not expect or cannot properly apply + to, the behavior is undefined. + @param context A pointer-sized user-defined value, which is passed + as the second parameter to the applier function, but is + otherwise unused by this function. If the context is not + what is expected by the applier function, the behavior is + undefined. +*/ +CF_EXPORT +void CFSetApplyFunction(CFSetRef theSet, CFSetApplierFunction applier, void *context); + +/*! + @function CFSetAddValue + Adds the value to the set if it is not already present. + @param theSet The set to which the value is to be added. If this + parameter is not a valid mutable CFSet, the behavior is + undefined. + @param value The value to add to the set. The value is retained by + the set using the retain callback provided when the set + was created. If the value is not of the sort expected by the + retain callback, the behavior is undefined. The count of the + set is increased by one. +*/ +CF_EXPORT +void CFSetAddValue(CFMutableSetRef theSet, const void *value); + +/*! + @function CFSetReplaceValue + Replaces the value in the set if it is present. + @param theSet The set to which the value is to be replaced. If this + parameter is not a valid mutable CFSet, the behavior is + undefined. + @param value The value to replace in the set. The equal() callback provided when + the set was created is used to compare. If the equal() callback + was NULL, pointer equality (in C, ==) is used. If a value, or + any of the values in the set, are not understood by the equal() + callback, the behavior is undefined. The value is retained by + the set using the retain callback provided when the set + was created. If the value is not of the sort expected by the + retain callback, the behavior is undefined. The count of the + set is increased by one. +*/ +CF_EXPORT +void CFSetReplaceValue(CFMutableSetRef theSet, const void *value); + +/*! + @function CFSetSetValue + Replaces the value in the set if it is present, or adds the value to + the set if it is absent. + @param theSet The set to which the value is to be replaced. If this + parameter is not a valid mutable CFSet, the behavior is + undefined. + @param value The value to set in the CFSet. The equal() callback provided when + the set was created is used to compare. If the equal() callback + was NULL, pointer equality (in C, ==) is used. If a value, or + any of the values in the set, are not understood by the equal() + callback, the behavior is undefined. The value is retained by + the set using the retain callback provided when the set + was created. If the value is not of the sort expected by the + retain callback, the behavior is undefined. The count of the + set is increased by one. +*/ +CF_EXPORT +void CFSetSetValue(CFMutableSetRef theSet, const void *value); + +/*! + @function CFSetRemoveValue + Removes the specified value from the set. + @param theSet The set from which the value is to be removed. + If this parameter is not a valid mutable CFSet, + the behavior is undefined. + @param value The value to remove. The equal() callback provided when + the set was created is used to compare. If the equal() callback + was NULL, pointer equality (in C, ==) is used. If a value, or + any of the values in the set, are not understood by the equal() + callback, the behavior is undefined. +*/ +CF_EXPORT +void CFSetRemoveValue(CFMutableSetRef theSet, const void *value); + +/*! + @function CFSetRemoveAllValues + Removes all the values from the set, making it empty. + @param theSet The set from which all of the values are to be + removed. If this parameter is not a valid mutable CFSet, + the behavior is undefined. +*/ +CF_EXPORT +void CFSetRemoveAllValues(CFMutableSetRef theSet); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFSET__ */ + diff --git a/include/CoreFoundation/CFSocket.h b/include/CoreFoundation/CFSocket.h new file mode 100644 index 0000000..1923a7f --- /dev/null +++ b/include/CoreFoundation/CFSocket.h @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFSocket.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFSOCKET__) +#define __COREFOUNDATION_CFSOCKET__ 1 + +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct __CFSocket * CFSocketRef; + +/* A CFSocket contains a native socket within a structure that can +be used to read from the socket in the background and make the data +thus read available using a runloop source. The callback used for +this may be of three types, as specified by the callBackTypes +argument when creating the CFSocket. + +If kCFSocketReadCallBack is used, then data will not be +automatically read, but the callback will be called when data +is available to be read, or a new child socket is waiting to be +accepted. + +If kCFSocketAcceptCallBack is used, then new child sockets will be +accepted and passed to the callback, with the data argument being +a pointer to a CFSocketNativeHandle. This is usable only with +connection rendezvous sockets. + +If kCFSocketDataCallBack is used, then data will be read in chunks +in the background and passed to the callback, with the data argument +being a CFDataRef. + +These three types are mutually exclusive, but any one of them may +have kCFSocketConnectCallBack added to it, if the socket will be +used to connect in the background. Connect in the background occurs +if CFSocketConnectToAddress is called with a negative timeout +value, in which case the call returns immediately, and a +kCFSocketConnectCallBack is generated when the connect finishes. +In this case the data argument is either NULL, or a pointer to +an SInt32 error code if the connect failed. kCFSocketConnectCallBack +will never be sent more than once for a given socket. + +The callback types may also have kCFSocketWriteCallBack added to +them, if large amounts of data are to be sent rapidly over the +socket and notification is desired when there is space in the +kernel buffers so that the socket is writable again. + +With a connection-oriented socket, if the connection is broken from the +other end, then one final kCFSocketReadCallBack or kCFSocketDataCallBack +will occur. In the case of kCFSocketReadCallBack, the underlying socket +will have 0 bytes available to read. In the case of kCFSocketDataCallBack, +the data argument will be a CFDataRef of length 0. + +There are socket flags that may be set to control whether callbacks of +a given type are automatically reenabled after they are triggered, and +whether the underlying native socket will be closed when the CFSocket +is invalidated. By default read, accept, and data callbacks are +automatically reenabled; write callbacks are not, and connect callbacks +may not be, since they are sent once only. Be careful about automatically +reenabling read and write callbacks, since this implies that the +callbacks will be sent repeatedly if the socket remains readable or +writable respectively. Be sure to set these flags only for callbacks +that your CFSocket actually possesses; the result of setting them for +other callback types is undefined. + +Individual callbacks may also be enabled and disabled manually, whether +they are automatically reenabled or not. If they are not automatically +reenabled, then they will need to be manually reenabled when the callback +is ready to be received again (and not sooner). Even if they are +automatically reenabled, there may be occasions when it will be useful +to be able to manually disable them temporarily and then reenable them. +Be sure to enable and disable only callbacks that your CFSocket actually +possesses; the result of enabling and disabling other callback types is +undefined. + +By default the underlying native socket will be closed when the CFSocket +is invalidated, but it will not be if kCFSocketCloseOnInvalidate is +turned off. This can be useful in order to destroy a CFSocket but +continue to use the underlying native socket. The CFSocket must +still be invalidated when it will no longer be used. Do not in +either case close the underlying native socket without invalidating +the CFSocket. + +Addresses are stored as CFDatas containing a struct sockaddr +appropriate for the protocol family; make sure that all fields are +filled in properly when passing in an address. + +*/ + +/* Values for CFSocketError */ +typedef CF_ENUM(CFIndex, CFSocketError) { + kCFSocketSuccess = 0, + kCFSocketError = -1L, + kCFSocketTimeout = -2L +}; + +typedef struct { + SInt32 protocolFamily; + SInt32 socketType; + SInt32 protocol; + CFDataRef address; +} CFSocketSignature; + +/* Values for CFSocketCallBackType */ +typedef CF_OPTIONS(CFOptionFlags, CFSocketCallBackType) { + kCFSocketNoCallBack = 0, + kCFSocketReadCallBack = 1, + kCFSocketAcceptCallBack = 2, + kCFSocketDataCallBack = 3, + kCFSocketConnectCallBack = 4, + kCFSocketWriteCallBack = 8 +}; + +/* Socket flags */ +enum { + kCFSocketAutomaticallyReenableReadCallBack = 1, + kCFSocketAutomaticallyReenableAcceptCallBack = 2, + kCFSocketAutomaticallyReenableDataCallBack = 3, + kCFSocketAutomaticallyReenableWriteCallBack = 8, + kCFSocketLeaveErrors CF_ENUM_AVAILABLE(10_5, 2_0) = 64, + kCFSocketCloseOnInvalidate = 128 +}; + +typedef void (*CFSocketCallBack)(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info); +/* If the callback wishes to keep hold of address or data after the point that it returns, then it must copy them. */ + +typedef struct { + CFIndex version; + void * info; + const void *(*retain)(const void *info); + void (*release)(const void *info); + CFStringRef (*copyDescription)(const void *info); +} CFSocketContext; + +#if TARGET_OS_WIN32 +typedef uintptr_t CFSocketNativeHandle; +#else +typedef int CFSocketNativeHandle; +#endif + +CF_EXPORT CFTypeID CFSocketGetTypeID(void); + +CF_EXPORT CFSocketRef CFSocketCreate(CFAllocatorRef allocator, SInt32 protocolFamily, SInt32 socketType, SInt32 protocol, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context); +CF_EXPORT CFSocketRef CFSocketCreateWithNative(CFAllocatorRef allocator, CFSocketNativeHandle sock, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context); +CF_EXPORT CFSocketRef CFSocketCreateWithSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context); +/* CFSocketCreateWithSocketSignature() creates a socket of the requested type and binds its address (using CFSocketSetAddress()) to the requested address. If this fails, it returns NULL. */ +CF_EXPORT CFSocketRef CFSocketCreateConnectedToSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context, CFTimeInterval timeout); +/* CFSocketCreateConnectedToSocketSignature() creates a socket suitable for connecting to the requested type and address, and connects it (using CFSocketConnectToAddress()). If this fails, it returns NULL. */ + +CF_EXPORT CFSocketError CFSocketSetAddress(CFSocketRef s, CFDataRef address); +CF_EXPORT CFSocketError CFSocketConnectToAddress(CFSocketRef s, CFDataRef address, CFTimeInterval timeout); +CF_EXPORT void CFSocketInvalidate(CFSocketRef s); + +CF_EXPORT Boolean CFSocketIsValid(CFSocketRef s); +CF_EXPORT CFDataRef CFSocketCopyAddress(CFSocketRef s); +CF_EXPORT CFDataRef CFSocketCopyPeerAddress(CFSocketRef s); +CF_EXPORT void CFSocketGetContext(CFSocketRef s, CFSocketContext *context); +CF_EXPORT CFSocketNativeHandle CFSocketGetNative(CFSocketRef s); + +CF_EXPORT CFRunLoopSourceRef CFSocketCreateRunLoopSource(CFAllocatorRef allocator, CFSocketRef s, CFIndex order); + +CF_EXPORT CFOptionFlags CFSocketGetSocketFlags(CFSocketRef s); +CF_EXPORT void CFSocketSetSocketFlags(CFSocketRef s, CFOptionFlags flags); +CF_EXPORT void CFSocketDisableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes); +CF_EXPORT void CFSocketEnableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes); + + +/* For convenience, a function is provided to send data using the socket with a timeout. The timeout will be used only if the specified value is positive. The address should be left NULL if the socket is already connected. */ +CF_EXPORT CFSocketError CFSocketSendData(CFSocketRef s, CFDataRef address, CFDataRef data, CFTimeInterval timeout); + +/* Generic name registry functionality (CFSocketRegisterValue, +CFSocketCopyRegisteredValue) allows the registration of any property +list type. Functions specific to CFSockets (CFSocketRegisterSocketData, +CFSocketCopyRegisteredSocketData) register a CFData containing the +components of a socket signature (protocol family, socket type, +protocol, and address). In each function the nameServerSignature +may be NULL, or any component of it may be 0, to use default values +(TCP, INADDR_LOOPBACK, port as set). Name registration servers might +not allow registration with other than TCP and INADDR_LOOPBACK. +The actual address of the server responding to a query may be obtained +by using the nameServerAddress argument. This address, the address +returned by CFSocketCopyRegisteredSocketSignature, and the value +returned by CFSocketCopyRegisteredValue must (if non-null) be released +by the caller. CFSocketUnregister removes any registration associated +with the specified name. +*/ + +CF_EXPORT CFSocketError CFSocketRegisterValue(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, CFPropertyListRef value); +CF_EXPORT CFSocketError CFSocketCopyRegisteredValue(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, CFPropertyListRef *value, CFDataRef *nameServerAddress); + +CF_EXPORT CFSocketError CFSocketRegisterSocketSignature(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, const CFSocketSignature *signature); +CF_EXPORT CFSocketError CFSocketCopyRegisteredSocketSignature(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name, CFSocketSignature *signature, CFDataRef *nameServerAddress); + +CF_EXPORT CFSocketError CFSocketUnregister(const CFSocketSignature *nameServerSignature, CFTimeInterval timeout, CFStringRef name); + +CF_EXPORT void CFSocketSetDefaultNameRegistryPortNumber(UInt16 port); +CF_EXPORT UInt16 CFSocketGetDefaultNameRegistryPortNumber(void); + +/* Constants used in name registry server communications */ +CF_EXPORT const CFStringRef kCFSocketCommandKey; +CF_EXPORT const CFStringRef kCFSocketNameKey; +CF_EXPORT const CFStringRef kCFSocketValueKey; +CF_EXPORT const CFStringRef kCFSocketResultKey; +CF_EXPORT const CFStringRef kCFSocketErrorKey; +CF_EXPORT const CFStringRef kCFSocketRegisterCommand; +CF_EXPORT const CFStringRef kCFSocketRetrieveCommand; + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFSOCKET__ */ + diff --git a/include/CoreFoundation/CFStorage.h b/include/CoreFoundation/CFStorage.h new file mode 100644 index 0000000..4cddf86 --- /dev/null +++ b/include/CoreFoundation/CFStorage.h @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFStorage.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ +/*! + @header CFStorage +CFStorage stores an array of arbitrary-sized values. There are no callbacks; +all that is provided about the values is the size, and the appropriate number +of bytes are copied in and out of the CFStorage. + +CFStorage uses a balanced tree to store the values, and is most appropriate +for situations where potentially a large number values (more than a hundred +bytes' worth) will be stored and there will be a lot of editing (insertions and deletions). + +Getting to an item is O(log n), although caching the last result often reduces this +to a constant time. + +The overhead of CFStorage is 48 bytes. There is no per item overhead; the +non-leaf nodes in the tree cost 20 bytes each, and the worst case extra +capacity (unused space in the leaves) is 12%, typically much less. + +Because CFStorage does not necessarily use a single block of memory to store the values, +when you ask for a value, you get back the pointer to the value and optionally +the range of other values that are consecutive and thus reachable as if the +storage was a single block. +*/ + +#if !defined(__COREFOUNDATION_CFSTORAGE__) +#define __COREFOUNDATION_CFSTORAGE__ 1 + +#include + +typedef CF_OPTIONS(CFOptionFlags, CFStorageEnumerationOptionFlags) { + kCFStorageEnumerationConcurrent = (1UL << 0) /* Allow enumeration to proceed concurrently */ +}; + +CF_EXTERN_C_BEGIN + +/*! + @typedef CFStorageRef + This is the type of a reference to a CFStorage instance. +*/ +typedef struct __CFStorage *CFStorageRef; + +/*! + @typedef CFStorageApplierFunction + Type of the callback function used by the apply functions of + CFStorage. + @param value The current value from the storage. + @param context The user-defined context parameter given to the apply + function. +*/ +typedef void (*CFStorageApplierFunction)(const void *val, void *context); + +/*! + @typedef CFStorageRangeApplierBlock + Type of the callback block used by the apply functions of + CFStorage + @param val A pointer to a range of values, numbering range.length + @param range The range of values. This will always be a subrange of the range + passed to the apply function. Do not try to modify the contents of the vals pointer, because + there is no guarantee it points into the contents of the CFStorage object. + @param stop An "out" parameter that, if set to true from within the block, indicates that the enumeration may stop. + +*/ +#if __BLOCKS__ +typedef void (^CFStorageApplierBlock)(const void *vals, CFRange range, bool *stop); +#endif + +/*! + @function CFStorageGetTypeID + Returns the type identifier of all CFStorage instances. +*/ +CF_EXPORT CFTypeID CFStorageGetTypeID(void); + +/*! + @function CFStorageCreate + Creates a new mutable storage with elements of the given size. + @param alloc The CFAllocator which should be used to allocate + memory for the set and its storage for values. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param valueSizeInBytes The size in bytes of each of the elements + to be stored in the storage. If this value is zero or + negative, the result is undefined. + @result A reference to the new CFStorage instance. +*/ +CF_EXPORT CFStorageRef CFStorageCreate(CFAllocatorRef alloc, CFIndex valueSizeInBytes); + +/*! + @function CFStorageInsertValues + Allocates space for range.length values at location range.location. Use + CFStorageReplaceValues() to set those values. + @param storage The storage to which the values are to be inserted. + If this parameter is not a valid CFStorage, the behavior is undefined. + @param range The range of values within the storage to insert. The + range location must be at least zero and not exceed the count of the storage. + Values at indexes equal to or greater than the range location have their indexes + increased by the length of the range. Thus this creates a gap in the storage + equal to the length of the given range. If the range length is negative, the + behavior is undefined. The range may be empty (length 0), + in which case there is no effect. + +*/ +CF_EXPORT void CFStorageInsertValues(CFStorageRef storage, CFRange range); + +/*! + @function CFStorageDeleteValues + Deletes the values of the storage in the specified range. + @param storage The storage from which the values are to be deleted. + If this parameter is not a valid CFStorage, the behavior is undefined. + @param range The range of values within the storage to delete. If the + range location or end point (defined by the location plus + length minus 1) are outside the index space of the storage (0 + to N inclusive, where N is the count of the storage), the + behavior is undefined. If the range length is negative, the + behavior is undefined. The range may be empty (length 0), + in which case no values are deleted. +*/ +CF_EXPORT void CFStorageDeleteValues(CFStorageRef storage, CFRange range); + +/*! + @function CFStorageGetCount + Returns the number of values currently in the storage. + @param storage The storage to be queried. If this parameter is not a valid + CFStorage, the behavior is undefined. + @result The number of values in the storage. +*/ +CF_EXPORT CFIndex CFStorageGetCount(CFStorageRef storage); + +/*! + @function CFStorageGetValueAtIndex + Returns a pointer to the specified value. The pointer is mutable and may be used to + get or set the value. This is considered to be a mutating function, and so calling this + while accessing the CFStorage from another thread is undefined behavior, + even if you do not set a value. To access the CFStorage in a non-mutating + manner, use the more efficient CFStorageGetConstValueAtIndex(). + @param storage The storage to be queried. If this parameter is not a + valid CFStorage, the behavior is undefined. + @param idx The index of the value to retrieve. If the index is + outside the index space of the storage (0 to N-1 inclusive, + where N is the count of the storage), the behavior is + undefined. + @param validConsecutiveValueRange This parameter is a C pointer to a CFRange. + If NULL is specified, this argument is ignored; otherwise, the range + is set to the range of values that may be accessed via an offset from the result pointer. + The range location is set to the index of the lowest consecutive + value and the range length is set to the count of consecutive values. + @result The value with the given index in the storage. +*/ +CF_EXPORT void *CFStorageGetValueAtIndex(CFStorageRef storage, CFIndex idx, CFRange *validConsecutiveValueRange); + +/*! + @function CFStorageGetConstValueAtIndex + Returns a pointer to the specified value. The pointer is immutable and may + only be used to get the value. This is not considered to be a mutating function, + so it is safe to call this concurrently with other non-mutating functions. Furthermore, + this is often more efficient than CFStorageGetValueAtIndex(), so it should be used + in preference to that function when possible. + @param storage The storage to be queried. If this parameter is not a + valid CFStorage, the behavior is undefined. + @param idx The index of the value to retrieve. If the index is + outside the index space of the storage (0 to N-1 inclusive, + where N is the count of the storage), the behavior is + undefined. + @param validConsecutiveValueRange This parameter is a C pointer to a CFRange. + If NULL is specified, this argument is ignored; otherwise, the range + is set to the range of values that may be accessed via an offset from the result pointer. + The range location is set to the index of the lowest consecutive + value and the range length is set to the count of consecutive values. + @result The value with the given index in the storage. +*/ +CF_EXPORT const void *CFStorageGetConstValueAtIndex(CFStorageRef storage, CFIndex idx, CFRange *validConsecutiveValueRange); + +/*! + @function CFStorageGetValues + Fills the buffer with values from the storage. + @param storage The storage to be queried. If this parameter is not a + valid CFStorage, the behavior is undefined. + @param range The range of values within the storage to retrieve. If + the range location or end point (defined by the location + plus length minus 1) are outside the index space of the + storage (0 to N-1 inclusive, where N is the count of the + storage), the behavior is undefined. If the range length is + negative, the behavior is undefined. The range may be empty + (length 0), in which case no values are put into the buffer. + @param values A C array of to be filled with values from the storage. + The values in the C array are ordered + in the same order in which they appear in the storage. If this + parameter is not a valid pointer to a C array of at least + range.length pointers, the behavior is undefined. +*/ +CF_EXPORT void CFStorageGetValues(CFStorageRef storage, CFRange range, void *values); + +/*! + @function CFStorageApplyFunction + Calls a function once for each value in the set. + @param storage The storage to be operated upon. If this parameter is not + a valid CFStorage, the behavior is undefined. + @param range The range of values within the storage to operate on. If the + range location or end point (defined by the location plus + length minus 1) are outside the index space of the storage (0 + to N inclusive, where N is the count of the storage), the + behavior is undefined. If the range length is negative, the + behavior is undefined. The range may be empty (length 0), + in which case the no values are operated on. + @param applier The callback function to call once for each value in + the given storage. If this parameter is not a + pointer to a function of the correct prototype, the behavior + is undefined. If there are values in the storage which the + applier function does not expect or cannot properly apply + to, the behavior is undefined. + @param context A pointer-sized user-defined value, which is passed + as the second parameter to the applier function, but is + otherwise unused by this function. If the context is not + what is expected by the applier function, the behavior is + undefined. +*/ +CF_EXPORT void CFStorageApplyFunction(CFStorageRef storage, CFRange range, CFStorageApplierFunction applier, void *context); + +/*! + @function CFStorageApplyBlock + Enumerates ranges of stored objects with a block. + @param storage The storage to be operated upon. If this parameter is not + a valid CFStorage, the behavior is undefined. + @param range The range of values within the storage to operate on. If the + sum of the range location and length is larger than the + count of the storage, the behavior is undefined. If the + range location or length is negative, the behavior is undefined. + @param options Options controlling how the enumeration may proceed. + @param applier The callback block. The block is passed a pointer to + a buffer of contiguous objects in the storage, and the range of stored + values represented by the buffer. If the block modifies the + contents of the buffer, the behavior is undefined. If the block modifies + the contents of the CFStorage, the behavior is undefined. + + */ +#if __BLOCKS__ +CF_EXPORT void CFStorageApplyBlock(CFStorageRef storage, CFRange range, CFStorageEnumerationOptionFlags options, CFStorageApplierBlock applier); +#endif + + +/*! + @function CFStorageCreateWithSubrange + Returns a new CFStorage that contains a portion of an existing CFStorage. + @param storage The storage to be operated upon. If this parameter is not + a valid CFStorage, the behavior is undefined. + @param range The range of values within the storage to operate on. If the + sum of the range location and length is larger than the + count of the storage, the behavior is undefined. If the + range location or length is negative, the behavior is undefined. + @result A reference to a new CFStorage containing a byte-for-byte copy of + the objects in the range. This may use copy-on-write techniques + to allow efficient implementation. + */ +CF_EXPORT CFStorageRef CFStorageCreateWithSubrange(CFStorageRef storage, CFRange range); + +/*! + @function CFStorageReplaceValues + Replaces a range of values in the storage. + @param storage The storage from which the specified values are to be + removed. If this parameter is not a valid CFStorage, + the behavior is undefined. + @param range The range of values within the storage to replace. If the + range location or end point (defined by the location plus + length minus 1) are outside the index space of the storage (0 + to N inclusive, where N is the count of the storage), the + behavior is undefined. If the range length is negative, the + behavior is undefined. The range may be empty (length 0), + in which case the new values are merely inserted at the + range location. + @param values A C array of the values to be copied into the storage. + The new values in the storage are ordered in the same order + in which they appear in this C array. This parameter may be NULL + if the range length is 0. This C array is not changed or freed by + this function. If this parameter is not a valid pointer to a C array of at least + range length pointers, the behavior is undefined. +*/ +CF_EXPORT void CFStorageReplaceValues(CFStorageRef storage, CFRange range, const void *values); + +/* Private stuff... +*/ +CF_EXPORT CFIndex __CFStorageGetCapacity(CFStorageRef storage); +CF_EXPORT CFIndex __CFStorageGetValueSize(CFStorageRef storage); +CF_EXPORT void __CFStorageSetAlwaysFrozen(CFStorageRef storage, bool alwaysFrozen); + + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFSTORAGE__ */ + diff --git a/include/CoreFoundation/CFStream.h b/include/CoreFoundation/CFStream.h new file mode 100644 index 0000000..16a37f2 --- /dev/null +++ b/include/CoreFoundation/CFStream.h @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFStream.h + Copyright (c) 2000-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFSTREAM__) +#define __COREFOUNDATION_CFSTREAM__ 1 + +#include +#include +#include +#include +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef CF_ENUM(CFIndex, CFStreamStatus) { + kCFStreamStatusNotOpen = 0, + kCFStreamStatusOpening, /* open is in-progress */ + kCFStreamStatusOpen, + kCFStreamStatusReading, + kCFStreamStatusWriting, + kCFStreamStatusAtEnd, /* no further bytes can be read/written */ + kCFStreamStatusClosed, + kCFStreamStatusError +}; + +typedef CF_OPTIONS(CFOptionFlags, CFStreamEventType) { + kCFStreamEventNone = 0, + kCFStreamEventOpenCompleted = 1, + kCFStreamEventHasBytesAvailable = 2, + kCFStreamEventCanAcceptBytes = 4, + kCFStreamEventErrorOccurred = 8, + kCFStreamEventEndEncountered = 16 +}; + +typedef struct { + CFIndex version; + void *info; + void *(*retain)(void *info); + void (*release)(void *info); + CFStringRef (*copyDescription)(void *info); +} CFStreamClientContext; + +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSInputStream) __CFReadStream * CFReadStreamRef; +typedef struct CF_BRIDGED_MUTABLE_TYPE(NSOutputStream) __CFWriteStream * CFWriteStreamRef; + +typedef void (*CFReadStreamClientCallBack)(CFReadStreamRef stream, CFStreamEventType type, void *clientCallBackInfo); +typedef void (*CFWriteStreamClientCallBack)(CFWriteStreamRef stream, CFStreamEventType type, void *clientCallBackInfo); + +CF_EXPORT +CFTypeID CFReadStreamGetTypeID(void); +CF_EXPORT +CFTypeID CFWriteStreamGetTypeID(void); + +/* Memory streams */ + +/* Value will be a CFData containing all bytes thusfar written; used to recover the data written to a memory write stream. */ +CF_EXPORT +const CFStringRef kCFStreamPropertyDataWritten; + +/* Pass kCFAllocatorNull for bytesDeallocator to prevent CFReadStream from deallocating bytes; otherwise, CFReadStream will deallocate bytes when the stream is destroyed */ +CF_EXPORT +CFReadStreamRef CFReadStreamCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex length, CFAllocatorRef bytesDeallocator); + +/* The stream writes into the buffer given; when bufferCapacity is exhausted, the stream is exhausted (status becomes kCFStreamStatusAtEnd) */ +CF_EXPORT +CFWriteStreamRef CFWriteStreamCreateWithBuffer(CFAllocatorRef alloc, UInt8 *buffer, CFIndex bufferCapacity); + +/* New buffers are allocated from bufferAllocator as bytes are written to the stream. At any point, you can recover the bytes thusfar written by asking for the property kCFStreamPropertyDataWritten, above */ +CF_EXPORT +CFWriteStreamRef CFWriteStreamCreateWithAllocatedBuffers(CFAllocatorRef alloc, CFAllocatorRef bufferAllocator); + +/* File streams */ +CF_EXPORT +CFReadStreamRef CFReadStreamCreateWithFile(CFAllocatorRef alloc, CFURLRef fileURL); +CF_EXPORT +CFWriteStreamRef CFWriteStreamCreateWithFile(CFAllocatorRef alloc, CFURLRef fileURL); +CF_IMPLICIT_BRIDGING_DISABLED +CF_EXPORT +void CFStreamCreateBoundPair(CFAllocatorRef alloc, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream, CFIndex transferBufferSize); +CF_IMPLICIT_BRIDGING_ENABLED + +/* Property for file write streams; value should be a CFBoolean. Set to TRUE to append to a file, rather than to replace its contents */ +CF_EXPORT +const CFStringRef kCFStreamPropertyAppendToFile; + +CF_EXPORT +const CFStringRef kCFStreamPropertyFileCurrentOffset; // Value is a CFNumber + + +/* Socket stream properties */ + +/* Value will be a CFData containing the native handle */ +CF_EXPORT +const CFStringRef kCFStreamPropertySocketNativeHandle; + +/* Value will be a CFString, or NULL if unknown */ +CF_EXPORT +const CFStringRef kCFStreamPropertySocketRemoteHostName; + +/* Value will be a CFNumber, or NULL if unknown */ +CF_EXPORT +const CFStringRef kCFStreamPropertySocketRemotePortNumber; + +CF_IMPLICIT_BRIDGING_DISABLED +/* Socket streams; the returned streams are paired such that they use the same socket; pass NULL if you want only the read stream or the write stream */ +CF_EXPORT +void CFStreamCreatePairWithSocket(CFAllocatorRef alloc, CFSocketNativeHandle sock, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream); +CF_EXPORT +void CFStreamCreatePairWithSocketToHost(CFAllocatorRef alloc, CFStringRef host, UInt32 port, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream); +CF_EXPORT +void CFStreamCreatePairWithPeerSocketSignature(CFAllocatorRef alloc, const CFSocketSignature *signature, CFReadStreamRef *readStream, CFWriteStreamRef *writeStream); +CF_IMPLICIT_BRIDGING_ENABLED + + +/* Returns the current state of the stream */ +CF_EXPORT +CFStreamStatus CFReadStreamGetStatus(CFReadStreamRef stream); +CF_EXPORT +CFStreamStatus CFWriteStreamGetStatus(CFWriteStreamRef stream); + +/* Returns NULL if no error has occurred; otherwise returns the error. */ +CF_EXPORT +CFErrorRef CFReadStreamCopyError(CFReadStreamRef stream) CF_AVAILABLE(10_5, 2_0); +CF_EXPORT +CFErrorRef CFWriteStreamCopyError(CFWriteStreamRef stream) CF_AVAILABLE(10_5, 2_0); + +/* Returns success/failure. Opening a stream causes it to reserve all the system + resources it requires. If the stream can open non-blocking, this will always + return TRUE; listen to the run loop source to find out when the open completes + and whether it was successful, or poll using CFRead/WriteStreamGetStatus(), waiting + for a status of kCFStreamStatusOpen or kCFStreamStatusError. */ +CF_EXPORT +Boolean CFReadStreamOpen(CFReadStreamRef stream); +CF_EXPORT +Boolean CFWriteStreamOpen(CFWriteStreamRef stream); + +/* Terminates the flow of bytes; releases any system resources required by the + stream. The stream may not fail to close. You may call CFStreamClose() to + effectively abort a stream. */ +CF_EXPORT +void CFReadStreamClose(CFReadStreamRef stream); +CF_EXPORT +void CFWriteStreamClose(CFWriteStreamRef stream); + +/* Whether there is data currently available for reading; returns TRUE if it's + impossible to tell without trying */ +CF_EXPORT +Boolean CFReadStreamHasBytesAvailable(CFReadStreamRef stream); + +/* Returns the number of bytes read, or -1 if an error occurs preventing any + bytes from being read, or 0 if the stream's end was encountered. + It is an error to try and read from a stream that hasn't been opened first. + This call will block until at least one byte is available; it will NOT block + until the entire buffer can be filled. To avoid blocking, either poll using + CFReadStreamHasBytesAvailable() or use the run loop and listen for the + kCFStreamCanRead event for notification of data available. */ +CF_EXPORT +CFIndex CFReadStreamRead(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength); + +/* Returns a pointer to an internal buffer if possible (setting *numBytesRead + to the length of the returned buffer), otherwise returns NULL; guaranteed + to return in O(1). Bytes returned in the buffer are considered read from + the stream; if maxBytesToRead is greater than 0, not more than maxBytesToRead + will be returned. If maxBytesToRead is less than or equal to zero, as many bytes + as are readily available will be returned. The returned buffer is good only + until the next stream operation called on the stream. Caller should neither + change the contents of the returned buffer nor attempt to deallocate the buffer; + it is still owned by the stream. */ +CF_EXPORT +const UInt8 *CFReadStreamGetBuffer(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead); + +/* Whether the stream can currently be written to without blocking; + returns TRUE if it's impossible to tell without trying */ +CF_EXPORT +Boolean CFWriteStreamCanAcceptBytes(CFWriteStreamRef stream); + +/* Returns the number of bytes successfully written, -1 if an error has + occurred, or 0 if the stream has been filled to capacity (for fixed-length + streams). If the stream is not full, this call will block until at least + one byte is written. To avoid blocking, either poll via CFWriteStreamCanAcceptBytes + or use the run loop and listen for the kCFStreamCanWrite event. */ +CF_EXPORT +CFIndex CFWriteStreamWrite(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength); + +/* Particular streams can name properties and assign meanings to them; you + access these properties through the following calls. A property is any interesting + information about the stream other than the data being transmitted itself. + Examples include the headers from an HTTP transmission, or the expected + number of bytes, or permission information, etc. Properties that can be set + configure the behavior of the stream, and may only be settable at particular times + (like before the stream has been opened). See the documentation for particular + properties to determine their get- and set-ability. */ +CF_EXPORT +CFTypeRef CFReadStreamCopyProperty(CFReadStreamRef stream, CFStringRef propertyName); +CF_EXPORT +CFTypeRef CFWriteStreamCopyProperty(CFWriteStreamRef stream, CFStringRef propertyName); + +/* Returns TRUE if the stream recognizes and accepts the given property-value pair; + FALSE otherwise. */ +CF_EXPORT +Boolean CFReadStreamSetProperty(CFReadStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue); +CF_EXPORT +Boolean CFWriteStreamSetProperty(CFWriteStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue); + +/* Asynchronous processing - If you wish to neither poll nor block, you may register + a client to hear about interesting events that occur on a stream. Only one client + per stream is allowed; registering a new client replaces the previous one. + + Once you have set a client, the stream must be scheduled to provide the context in + which the client will be called. Streams may be scheduled on a single dispatch queue + or on one or more run loops. If scheduled on a run loop, it is the caller's responsibility + to ensure that at least one of the scheduled run loops is being run. + + NOTE: Unlike other CoreFoundation APIs, pasing a NULL clientContext here will remove + the client. If you do not care about the client context (i.e. your only concern + is that your callback be called), you should pass in a valid context where every + entry is 0 or NULL. + +*/ + +CF_EXPORT +Boolean CFReadStreamSetClient(CFReadStreamRef stream, CFOptionFlags streamEvents, CFReadStreamClientCallBack clientCB, CFStreamClientContext *clientContext); +CF_EXPORT +Boolean CFWriteStreamSetClient(CFWriteStreamRef stream, CFOptionFlags streamEvents, CFWriteStreamClientCallBack clientCB, CFStreamClientContext *clientContext); + +CF_EXPORT +void CFReadStreamScheduleWithRunLoop(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode); +CF_EXPORT +void CFWriteStreamScheduleWithRunLoop(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode); + +CF_EXPORT +void CFReadStreamUnscheduleFromRunLoop(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode); +CF_EXPORT +void CFWriteStreamUnscheduleFromRunLoop(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode); + +/* + * Specify the dispatch queue upon which the client callbacks will be invoked. + * Passing NULL for the queue will prevent future callbacks from being invoked. + * Specifying a dispatch queue using this API will unschedule the stream from + * any run loops it had previously been scheduled upon - similarly, scheduling + * with a runloop will disassociate the stream from any existing dispatch queue. + */ +CF_EXPORT +void CFReadStreamSetDispatchQueue(CFReadStreamRef stream, dispatch_queue_t q) CF_AVAILABLE(10_9, 7_0); + +CF_EXPORT +void CFWriteStreamSetDispatchQueue(CFWriteStreamRef stream, dispatch_queue_t q) CF_AVAILABLE(10_9, 7_0); + +/* + * Returns the previously set dispatch queue with an incremented retain count. + * Note that the stream's queue may have been set to NULL if the stream was + * scheduled on a runloop subsequent to it having had a dispatch queue set. + */ +CF_EXPORT +dispatch_queue_t CFReadStreamCopyDispatchQueue(CFReadStreamRef stream) CF_AVAILABLE(10_9, 7_0); + +CF_EXPORT +dispatch_queue_t CFWriteStreamCopyDispatchQueue(CFWriteStreamRef stream) CF_AVAILABLE(10_9, 7_0); + +/* The following API is deprecated starting in 10.5; please use CFRead/WriteStreamCopyError(), above, instead */ +typedef CF_ENUM(CFIndex, CFStreamErrorDomain) { + kCFStreamErrorDomainCustom = -1L, /* custom to the kind of stream in question */ + kCFStreamErrorDomainPOSIX = 1, /* POSIX errno; interpret using */ + kCFStreamErrorDomainMacOSStatus /* OSStatus type from Carbon APIs; interpret using */ +}; + +typedef struct { + CFIndex domain; + SInt32 error; +} CFStreamError; +CF_EXPORT +CFStreamError CFReadStreamGetError(CFReadStreamRef stream); +CF_EXPORT +CFStreamError CFWriteStreamGetError(CFWriteStreamRef stream); + + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFSTREAM__ */ diff --git a/include/CoreFoundation/CFStreamAbstract.h b/include/CoreFoundation/CFStreamAbstract.h new file mode 100644 index 0000000..ac26664 --- /dev/null +++ b/include/CoreFoundation/CFStreamAbstract.h @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFStreamAbstract.h + Copyright (c) 2000-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFSTREAMABSTRACT__) +#define __COREFOUNDATION_CFSTREAMABSTRACT__ 1 + +#include + +CF_EXTERN_C_BEGIN + +/* During a stream's lifetime, the open callback will be called once, followed by any number of openCompleted calls (until openCompleted returns TRUE). Then any number of read/canRead or write/canWrite calls, then a single close call. copyProperty can be called at any time. prepareAsynch will be called exactly once when the stream's client is first configured. + + Expected semantics: + - open reserves any system resources that are needed. The stream may start the process of opening, returning TRUE immediately and setting openComplete to FALSE. When the open completes, _CFStreamSignalEvent should be called passing kCFStreamOpenCompletedEvent. openComplete should be set to TRUE only if the open operation completed in its entirety. + - openCompleted will only be called after open has been called, but before any kCFStreamOpenCompletedEvent has been received. Return TRUE, setting error.code to 0, if the open operation has completed. Return TRUE, setting error to the correct error code and domain if the open operation completed, but failed. Return FALSE if the open operation is still in-progress. If your open ever fails to complete (i.e. sets openComplete to FALSE), you must be implement the openCompleted callback. + - read should read into the given buffer, returning the number of bytes successfully read. read must block until at least one byte is available, but should not block until the entire buffer is filled; zero should only be returned if end-of-stream is encountered. atEOF should be set to true if the EOF is encountered, false otherwise. error.code should be set to zero if no error occurs; otherwise, error should be set to the appropriate values. + - getBuffer is an optimization to return an internal buffer of bytes read from the stream, and may return NULL. getBuffer itself may be NULL if the concrete implementation does not wish to provide an internal buffer. If implemented, it should set numBytesRead to the number of bytes available in the internal buffer (but should not exceed maxBytesToRead) and return a pointer to the base of the bytes. + - canRead will only be called once openCompleted reports that the stream has been successfully opened (or the initial open call succeeded). It should return whether there are bytes that can be read without blocking. + - write should write the bytes in the given buffer to the device, returning the number of bytes successfully written. write must block until at least one byte is written. error.code should be set to zero if no error occurs; otherwise, error should be set to the appropriate values. + - close should close the device, releasing any reserved system resources. close cannot fail (it may be called to abort the stream), and may be called at any time after open has been called. It will only be called once. + - copyProperty should return the value for the given property, or NULL if none exists. Composite streams (streams built on top of other streams) should take care to call CFStreamCopyProperty on the base stream if they do not recognize the property given, to give the underlying stream a chance to respond. + + In all cases, errors returned by reference will be initialized to NULL by the caller, and if they are set to non-NULL, will + be released by the caller +*/ + +typedef struct { + CFIndex version; /* == 2 */ + + void *(*create)(CFReadStreamRef stream, void *info); + void (*finalize)(CFReadStreamRef stream, void *info); + CFStringRef (*copyDescription)(CFReadStreamRef stream, void *info); + + Boolean (*open)(CFReadStreamRef stream, CFErrorRef *error, Boolean *openComplete, void *info); + Boolean (*openCompleted)(CFReadStreamRef stream, CFErrorRef *error, void *info); + CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, Boolean *atEOF, void *info); + const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFErrorRef *error, Boolean *atEOF, void *info); + Boolean (*canRead)(CFReadStreamRef stream, CFErrorRef *error, void *info); + void (*close)(CFReadStreamRef stream, void *info); + + CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info); + Boolean (*setProperty)(CFReadStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); + + void (*requestEvents)(CFReadStreamRef stream, CFOptionFlags streamEvents, void *info); + void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); + void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); +} CFReadStreamCallBacks; + +typedef struct { + CFIndex version; /* == 2 */ + + void *(*create)(CFWriteStreamRef stream, void *info); + void (*finalize)(CFWriteStreamRef stream, void *info); + CFStringRef (*copyDescription)(CFWriteStreamRef stream, void *info); + + Boolean (*open)(CFWriteStreamRef stream, CFErrorRef *error, Boolean *openComplete, void *info); + Boolean (*openCompleted)(CFWriteStreamRef stream, CFErrorRef *error, void *info); + CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, void *info); + Boolean (*canWrite)(CFWriteStreamRef stream, CFErrorRef *error, void *info); + void (*close)(CFWriteStreamRef stream, void *info); + + CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info); + Boolean (*setProperty)(CFWriteStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); + + void (*requestEvents)(CFWriteStreamRef stream, CFOptionFlags streamEvents, void *info); + void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); + void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); +} CFWriteStreamCallBacks; + +// Primitive creation mechanisms. +CF_EXPORT +CFReadStreamRef CFReadStreamCreate(CFAllocatorRef alloc, const CFReadStreamCallBacks *callbacks, void *info); +CF_EXPORT +CFWriteStreamRef CFWriteStreamCreate(CFAllocatorRef alloc, const CFWriteStreamCallBacks *callbacks, void *info); + +/* All the functions below can only be called when you are sure the stream in question was created via + CFReadStreamCreate() or CFWriteStreamCreate(), above. They are NOT safe for toll-free bridged objects, + so the caller must be sure the argument passed is not such an object. */ + +// To be called by the concrete stream implementation (the callbacks) when an event occurs. error may be NULL if event != kCFStreamEventErrorOccurred +// error should be a CFErrorRef if the callbacks are version 2 or later; otherwise it should be a (CFStreamError *). +CF_EXPORT +void CFReadStreamSignalEvent(CFReadStreamRef stream, CFStreamEventType event, const void *error); +CF_EXPORT +void CFWriteStreamSignalEvent(CFWriteStreamRef stream, CFStreamEventType event, const void *error); + +// These require that the stream allow the run loop to run once before delivering the event to its client. +// See the comment above CFRead/WriteStreamSignalEvent for interpretation of the error argument. +CF_EXPORT +void _CFReadStreamSignalEventDelayed(CFReadStreamRef stream, CFStreamEventType event, const void *error); +CF_EXPORT +void _CFWriteStreamSignalEventDelayed(CFWriteStreamRef stream, CFStreamEventType event, const void *error); + +CF_EXPORT +void _CFReadStreamClearEvent(CFReadStreamRef stream, CFStreamEventType event); +// Write variant not currently needed +//CF_EXPORT +//void _CFWriteStreamClearEvent(CFWriteStreamRef stream, CFStreamEventType event); + +// Convenience for concrete implementations to extract the info pointer given the stream. +CF_EXPORT +void *CFReadStreamGetInfoPointer(CFReadStreamRef stream); +CF_EXPORT +void *CFWriteStreamGetInfoPointer(CFWriteStreamRef stream); + +// Returns the client info pointer currently set on the stream. These should probably be made public one day. +CF_EXPORT +void *_CFReadStreamGetClient(CFReadStreamRef readStream); +CF_EXPORT +void *_CFWriteStreamGetClient(CFWriteStreamRef writeStream); + +// Returns an array of the runloops and modes on which the stream is currently scheduled +// Note that these are unretained mutable arrays - use the copy variant instead. +CF_EXPORT +CFArrayRef _CFReadStreamGetRunLoopsAndModes(CFReadStreamRef readStream); +CF_EXPORT +CFArrayRef _CFWriteStreamGetRunLoopsAndModes(CFWriteStreamRef writeStream); + +// Returns an array of the runloops and modes on which the stream is currently scheduled +CF_EXPORT +CFArrayRef _CFReadStreamCopyRunLoopsAndModes(CFReadStreamRef readStream); +CF_EXPORT +CFArrayRef _CFWriteStreamCopyRunLoopsAndModes(CFWriteStreamRef writeStream); + +/* Deprecated versions; here for backwards compatibility. */ +typedef struct { + CFIndex version; /* == 1 */ + void *(*create)(CFReadStreamRef stream, void *info); + void (*finalize)(CFReadStreamRef stream, void *info); + CFStringRef (*copyDescription)(CFReadStreamRef stream, void *info); + Boolean (*open)(CFReadStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); + Boolean (*openCompleted)(CFReadStreamRef stream, CFStreamError *error, void *info); + CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info); + const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info); + Boolean (*canRead)(CFReadStreamRef stream, void *info); + void (*close)(CFReadStreamRef stream, void *info); + CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info); + Boolean (*setProperty)(CFReadStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); + void (*requestEvents)(CFReadStreamRef stream, CFOptionFlags streamEvents, void *info); + void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); + void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); +} CFReadStreamCallBacksV1; + +typedef struct { + CFIndex version; /* == 1 */ + void *(*create)(CFWriteStreamRef stream, void *info); + void (*finalize)(CFWriteStreamRef stream, void *info); + CFStringRef (*copyDescription)(CFWriteStreamRef stream, void *info); + Boolean (*open)(CFWriteStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); + Boolean (*openCompleted)(CFWriteStreamRef stream, CFStreamError *error, void *info); + CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, void *info); + Boolean (*canWrite)(CFWriteStreamRef stream, void *info); + void (*close)(CFWriteStreamRef stream, void *info); + CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info); + Boolean (*setProperty)(CFWriteStreamRef stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); + void (*requestEvents)(CFWriteStreamRef stream, CFOptionFlags streamEvents, void *info); + void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); + void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); +} CFWriteStreamCallBacksV1; + +typedef struct { + CFIndex version; /* == 0 */ + Boolean (*open)(CFReadStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); + Boolean (*openCompleted)(CFReadStreamRef stream, CFStreamError *error, void *info); + CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info); + const UInt8 *(*getBuffer)(CFReadStreamRef stream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info); + Boolean (*canRead)(CFReadStreamRef stream, void *info); + void (*close)(CFReadStreamRef stream, void *info); + CFTypeRef (*copyProperty)(CFReadStreamRef stream, CFStringRef propertyName, void *info); + void (*schedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); + void (*unschedule)(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); +} CFReadStreamCallBacksV0; + +typedef struct { + CFIndex version; /* == 0 */ + Boolean (*open)(CFWriteStreamRef stream, CFStreamError *error, Boolean *openComplete, void *info); + Boolean (*openCompleted)(CFWriteStreamRef stream, CFStreamError *error, void *info); + CFIndex (*write)(CFWriteStreamRef stream, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, void *info); + Boolean (*canWrite)(CFWriteStreamRef stream, void *info); + void (*close)(CFWriteStreamRef stream, void *info); + CFTypeRef (*copyProperty)(CFWriteStreamRef stream, CFStringRef propertyName, void *info); + void (*schedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); + void (*unschedule)(CFWriteStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); +} CFWriteStreamCallBacksV0; + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFSTREAMABSTRACT__ */ diff --git a/include/CoreFoundation/CFStreamInternal.h b/include/CoreFoundation/CFStreamInternal.h new file mode 100644 index 0000000..c35a2de --- /dev/null +++ b/include/CoreFoundation/CFStreamInternal.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#if !defined(__COREFOUNDATION_CFSTREAMINTERNAL__) +#define __COREFOUNDATION_CFSTREAMINTERNAL__ 1 + +#include +#include +#include +#include + +CF_EXTERN_C_BEGIN + + +// Older versions of the callbacks; v0 callbacks match v1 callbacks, except that create, finalize, and copyDescription are missing. +typedef Boolean (*_CFStreamCBOpenV1)(struct _CFStream *stream, CFStreamError *error, Boolean *openComplete, void *info); +typedef Boolean (*_CFStreamCBOpenCompletedV1)(struct _CFStream *stream, CFStreamError *error, void *info); +typedef CFIndex (*_CFStreamCBReadV1)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info); +typedef const UInt8 *(*_CFStreamCBGetBufferV1)(CFReadStreamRef sream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info); +typedef Boolean (*_CFStreamCBCanReadV1)(CFReadStreamRef, void *info); +typedef CFIndex (*_CFStreamCBWriteV1)(CFWriteStreamRef, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, void *info); +typedef Boolean (*_CFStreamCBCanWriteV1)(CFWriteStreamRef, void *info); + +struct _CFStreamCallBacksV1 { + CFIndex version; + void *(*create)(struct _CFStream *stream, void *info); + void (*finalize)(struct _CFStream *stream, void *info); + CFStringRef (*copyDescription)(struct _CFStream *stream, void *info); + + _CFStreamCBOpenV1 open; + _CFStreamCBOpenCompletedV1 openCompleted; + _CFStreamCBReadV1 read; + _CFStreamCBGetBufferV1 getBuffer; + _CFStreamCBCanReadV1 canRead; + _CFStreamCBWriteV1 write; + _CFStreamCBCanWriteV1 canWrite; + void (*close)(struct _CFStream *stream, void *info); + + CFTypeRef (*copyProperty)(struct _CFStream *stream, CFStringRef propertyName, void *info); + Boolean (*setProperty)(struct _CFStream *stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); + void (*requestEvents)(struct _CFStream *stream, CFOptionFlags events, void *info); + void (*schedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); + void (*unschedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); +}; + +// These two are defined in CFSocketStream.c because that's where the glue for CFNetwork is. +CF_PRIVATE CFErrorRef _CFErrorFromStreamError(CFAllocatorRef alloc, CFStreamError *err); +CF_PRIVATE CFStreamError _CFStreamErrorFromError(CFErrorRef error); + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFSTREAMINTERNAL__ */ + + diff --git a/include/CoreFoundation/CFStreamPriv.h b/include/CoreFoundation/CFStreamPriv.h new file mode 100644 index 0000000..e598443 --- /dev/null +++ b/include/CoreFoundation/CFStreamPriv.h @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFStreamPriv.h + Copyright (c) 2000-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFSTREAMPRIV__) +#define __COREFOUNDATION_CFSTREAMPRIV__ 1 + +#include +#include +#include + +CF_EXTERN_C_BEGIN + +struct _CFStream; +struct _CFStreamClient { + CFStreamClientContext cbContext; + void (*cb)(struct _CFStream *, CFStreamEventType, void *); + CFOptionFlags when; + CFRunLoopSourceRef rlSource; + CFMutableArrayRef runLoopsAndModes; + CFOptionFlags whatToSignal; +}; + +#define CFStreamCurrentVersion 2 + +// A unified set of callbacks so we can use a single structure for all struct _CFStreams. +struct _CFStreamCallBacks { + CFIndex version; + void *(*create)(struct _CFStream *stream, void *info); + void (*finalize)(struct _CFStream *stream, void *info); + CFStringRef (*copyDescription)(struct _CFStream *stream, void *info); + + Boolean (*open)(struct _CFStream *stream, CFErrorRef *error, Boolean *openComplete, void *info); + Boolean (*openCompleted)(struct _CFStream *stream, CFErrorRef *error, void *info); + CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, Boolean *atEOF, void *info); + const UInt8 *(*getBuffer)(CFReadStreamRef sream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFErrorRef *error, Boolean *atEOF, void *info); + Boolean (*canRead)(CFReadStreamRef, CFErrorRef *error, void *info); + CFIndex (*write)(CFWriteStreamRef, const UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, void *info); + Boolean (*canWrite)(CFWriteStreamRef, CFErrorRef *error, void *info); + void (*close)(struct _CFStream *stream, void *info); + + CFTypeRef (*copyProperty)(struct _CFStream *stream, CFStringRef propertyName, void *info); + Boolean (*setProperty)(struct _CFStream *stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info); + void (*requestEvents)(struct _CFStream *stream, CFOptionFlags events, void *info); + void (*schedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); + void (*unschedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info); +}; + +struct _CFStream; + +CF_EXPORT void* _CFStreamGetInfoPointer(struct _CFStream* stream); + +// cb version must be > 0 +CF_EXPORT struct _CFStream *_CFStreamCreateWithConstantCallbacks(CFAllocatorRef alloc, void *info, const struct _CFStreamCallBacks *cb, Boolean isReading); + +// Only available for streams created with _CFStreamCreateWithConstantCallbacks, above. cb's version must be 1 +CF_EXPORT void _CFStreamSetInfoPointer(struct _CFStream *stream, void *info, const struct _CFStreamCallBacks *cb); + +/* +** _CFStreamSourceScheduleWithRunLoop +** +** Schedules the given run loop source on the given run loop and mode. It then +** adds the loop and mode pair to the runLoopsAndModes list. The list is +** simply a linear list of a loop reference followed by a mode reference. +** +** source Run loop source to be scheduled +** +** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled +** +** runLoop Run loop on which the source is being scheduled +** +** runLoopMode Run loop mode on which the source is being scheduled +*/ +CF_EXPORT +void _CFStreamSourceScheduleWithRunLoop(CFRunLoopSourceRef source, CFMutableArrayRef runLoopsAndModes, CFRunLoopRef runLoop, CFStringRef runLoopMode); + + +/* +** _CFStreamSourceUnscheduleFromRunLoop +** +** Unschedule the given source from the given run loop and mode. It then will +** guarantee that the source remains scheduled on the list of run loop and mode +** pairs in the runLoopsAndModes list. The list is simply a linear list of a +** loop reference followed by a mode reference. +** +** source Run loop source to be unscheduled +** +** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled +** +** runLoop Run loop from which the source is being unscheduled +** +** runLoopMode Run loop mode from which the source is being unscheduled +*/ +CF_EXPORT +void _CFStreamSourceUnscheduleFromRunLoop(CFRunLoopSourceRef source, CFMutableArrayRef runLoopsAndModes, CFRunLoopRef runLoop, CFStringRef runLoopMode); + + +/* +** _CFStreamSourceScheduleWithAllRunLoops +** +** Schedules the given run loop source on all the run loops and modes in the list. +** The list is simply a linear list of a loop reference followed by a mode reference. +** +** source Run loop source to be unscheduled +** +** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled +*/ +CF_EXPORT +void _CFStreamSourceScheduleWithAllRunLoops(CFRunLoopSourceRef source, CFArrayRef runLoopsAndModes); + + +/* +** _CFStreamSourceUnscheduleFromRunLoop +** +** Unschedule the given source from all the run loops and modes in the list. +** The list is simply a linear list of a loop reference followed by a mode +** reference. +** +** source Run loop source to be unscheduled +** +** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled +*/ +CF_EXPORT +void _CFStreamSourceUncheduleFromAllRunLoops(CFRunLoopSourceRef source, CFArrayRef runLoopsAndModes); + +CF_EXPORT +CFReadStreamRef _CFReadStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd); + +CF_EXPORT +CFWriteStreamRef _CFWriteStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd); + + + +#define SECURITY_NONE (0) +#define SECURITY_SSLv2 (1) +#define SECURITY_SSLv3 (2) +#define SECURITY_SSLv32 (3) +#define SECURITY_TLS (4) + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +// This symbol is exported from CFNetwork (see CFSocketStream.i). Only __MACH__ systems will +// get this symbol from CoreFoundation. +extern const int kCFStreamErrorDomainSSL; +#endif + +/* + * Additional SPI for CFNetwork for select side read buffering + */ +CF_EXPORT +Boolean __CFSocketGetBytesAvailable(CFSocketRef s, CFIndex* ctBytesAvailable); + +CF_EXPORT +CFIndex __CFSocketRead(CFSocketRef s, UInt8* buffer, CFIndex length, int* error); + +/* + * This define can be removed once 6030579 is removed + */ +#define CFNETWORK_6030579 1 + +CF_EXPORT +void __CFSocketSetSocketReadBufferAttrs(CFSocketRef s, CFTimeInterval timeout, CFIndex length); + +CF_EXTERN_C_END + +/* + * for CF{Read/Write}StreamCopyProperty created from a file. The + * result is a CFDataRef containing sizeof(int) bytes in machine byte + * ordering representing the file descriptor of the underlying open + * file. If the underlying file descriptor is not open, the property + * value will be NULL (as opposed to containing ((int) -1)). + */ +CF_EXPORT const CFStringRef _kCFStreamPropertyFileNativeHandle CF_AVAILABLE_IOS(5_0); + +#endif /* ! __COREFOUNDATION_CFSTREAMPRIV__ */ + diff --git a/include/CoreFoundation/CFString.h b/include/CoreFoundation/CFString.h new file mode 100644 index 0000000..9aaa942 --- /dev/null +++ b/include/CoreFoundation/CFString.h @@ -0,0 +1,891 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFString.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFSTRING__) +#define __COREFOUNDATION_CFSTRING__ 1 + +#include +#include +#include +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +/* +Please note: CFStrings are conceptually an array of Unicode characters. +However, in general, how a CFString stores this array is an implementation +detail. For instance, CFString might choose to use an array of 8-bit characters +to store its contents, or it might use multiple blocks of memory, or whatever. +This is especially true since CFString is toll-free bridged with NSString, enabling +any NSString instance to be used as a CFString. Furthermore, the implementation +may change depending on the default system encoding, the user's language, +or even a release or update of the OS. + +What this means is that you should use the following advanced functions with care: + + CFStringGetPascalStringPtr() + CFStringGetCStringPtr() + CFStringGetCharactersPtr() + +These functions are provided for optimization only. They will either return the desired +pointer quickly, in constant time, or they return NULL. They might choose to return NULL +for many reasons; for instance it's possible that for users running in different +languages these sometimes return NULL; or in a future OS release the first two might +switch to always returning NULL. Never observing NULL returns in your usages of these +functions does not mean they won't ever return NULL. (But note the CFStringGetCharactersPtr() +exception mentioned further below.) + +In your usages of these functions, if you get a NULL return, use the non-Ptr version +of the functions as shown in this example: + + char buffer[BUFSIZE]; + const char *ptr = CFStringGetCStringPtr(str, encoding); + if (ptr == NULL) { + if (CFStringGetCString(str, buffer, BUFSIZE, encoding)) ptr = buffer; + } + +Note that CFStringGetCString() or CFStringGetPascalString() calls might still fail --- but +that will happen in two circumstances only: The conversion from the UniChar contents of CFString +to the specified encoding fails, or the buffer is too small. If they fail, that means +the conversion was not possible. + +If you need a copy of the buffer in the above example, you might consider simply calling +CFStringGetCString() in all cases --- CFStringGetCStringPtr() is simply an optimization. + +In addition, the following functions, which create immutable CFStrings from developer +supplied buffers without copying the buffers, might have to actually copy +under certain circumstances (If they do copy, the buffer will be dealt with by the +"contentsDeallocator" argument.): + + CFStringCreateWithPascalStringNoCopy() + CFStringCreateWithCStringNoCopy() + CFStringCreateWithCharactersNoCopy() + +You should of course never depend on the backing store of these CFStrings being +what you provided, and in other no circumstance should you change the contents +of that buffer (given that would break the invariant about the CFString being immutable). + +Having said all this, there are actually ways to create a CFString where the backing store +is external, and can be manipulated by the developer or CFString itself: + + CFStringCreateMutableWithExternalCharactersNoCopy() + CFStringSetExternalCharactersNoCopy() + +A "contentsAllocator" is used to realloc or free the backing store by CFString. +kCFAllocatorNull can be provided to assure CFString will never realloc or free the buffer. +Developer can call CFStringSetExternalCharactersNoCopy() to update +CFString's idea of what's going on, if the buffer is changed externally. In these +strings, CFStringGetCharactersPtr() is guaranteed to return the external buffer. + +These functions are here to allow wrapping a buffer of UniChar characters in a CFString, +allowing the buffer to passed into CFString functions and also manipulated via CFString +mutation functions. In general, developers should not use this technique for all strings, +as it prevents CFString from using certain optimizations. +*/ + +/* Identifier for character encoding; the values are the same as Text Encoding Converter TextEncoding. +*/ +typedef UInt32 CFStringEncoding; + +/* Platform-independent built-in encodings; always available on all platforms. + Call CFStringGetSystemEncoding() to get the default system encoding. +*/ +#define kCFStringEncodingInvalidId (0xffffffffU) +typedef CF_ENUM(CFStringEncoding, CFStringBuiltInEncodings) { + kCFStringEncodingMacRoman = 0, + kCFStringEncodingWindowsLatin1 = 0x0500, /* ANSI codepage 1252 */ + kCFStringEncodingISOLatin1 = 0x0201, /* ISO 8859-1 */ + kCFStringEncodingNextStepLatin = 0x0B01, /* NextStep encoding*/ + kCFStringEncodingASCII = 0x0600, /* 0..127 (in creating CFString, values greater than 0x7F are treated as corresponding Unicode value) */ + kCFStringEncodingUnicode = 0x0100, /* kTextEncodingUnicodeDefault + kTextEncodingDefaultFormat (aka kUnicode16BitFormat) */ + kCFStringEncodingUTF8 = 0x08000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF8Format */ + kCFStringEncodingNonLossyASCII = 0x0BFF, /* 7bit Unicode variants used by Cocoa & Java */ + + kCFStringEncodingUTF16 = 0x0100, /* kTextEncodingUnicodeDefault + kUnicodeUTF16Format (alias of kCFStringEncodingUnicode) */ + kCFStringEncodingUTF16BE = 0x10000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF16BEFormat */ + kCFStringEncodingUTF16LE = 0x14000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF16LEFormat */ + + kCFStringEncodingUTF32 = 0x0c000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF32Format */ + kCFStringEncodingUTF32BE = 0x18000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF32BEFormat */ + kCFStringEncodingUTF32LE = 0x1c000100 /* kTextEncodingUnicodeDefault + kUnicodeUTF32LEFormat */ +}; + + +/* CFString type ID */ +CF_EXPORT +CFTypeID CFStringGetTypeID(void); + +/* CFSTR() allows creation of compile-time constant CFStringRefs; the argument +should be a constant C-string. + +CFSTR(), not being a "Copy" or "Create" function, does not return a new +reference for you. So, you should not release the return value. This is +much like constant C or Pascal strings --- when you use "hello world" +in a program, you do not free it. + +However, strings returned from CFSTR() can be retained and released in a +properly nested fashion, just like any other CF type. That is, if you pass +a CFSTR() return value to a function such as SetMenuItemWithCFString(), the +function can retain it, then later, when it's done with it, it can release it. + +Non-7 bit characters (that is, above 127) in CFSTR() are supported, although care must +be taken in dealing with files containing them. If you can trust your editor and tools +to deal with non-ASCII characters in the source code, then you can use them directly +in CFSTR(); otherwise, you can represent such characters with their escaped octal +equivalents in the encoding the compiler will use to interpret them (for instance, +O-umlaut is \303\226 in UTF-8). UTF-8 is the recommended encoding here, +since it is the default choice with Mac OS X developer tools. +*/ +#if TARGET_OS_WIN32 || TARGET_OS_LINUX +#undef __CONSTANT_CFSTRINGS__ +#endif + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr "")) +#else +#define CFSTR(cStr) __CFStringMakeConstantString("" cStr "") +#endif + +#if defined(__GNUC__) && (__GNUC__*10+__GNUC_MINOR__ >= 42) && defined(__APPLE_CC__) && (__APPLE_CC__ > 1) && !defined(__INTEL_COMPILER) && (TARGET_OS_MAC || TARGET_OS_EMBEDDED) +#define CF_FORMAT_FUNCTION(F,A) __attribute__((format(CFString, F, A))) +#define CF_FORMAT_ARGUMENT(A) __attribute__((format_arg(A))) +#else +#define CF_FORMAT_FUNCTION(F,A) +#define CF_FORMAT_ARGUMENT(A) +#endif + +/*** Immutable string creation functions ***/ + +/* Functions to create basic immutable strings. The provided allocator is used for all memory activity in these functions. +*/ + +/* The following four functions copy the provided buffer into CFString's internal storage. */ +CF_EXPORT +CFStringRef CFStringCreateWithPascalString(CFAllocatorRef alloc, ConstStr255Param pStr, CFStringEncoding encoding); + +CF_EXPORT +CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding); + +/* The following takes an explicit length, and allows you to specify whether the data is an external format --- that is, whether to pay attention to the BOM character (if any) and do byte swapping if necessary +*/ +CF_EXPORT +CFStringRef CFStringCreateWithBytes(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalRepresentation); + +CF_EXPORT +CFStringRef CFStringCreateWithCharacters(CFAllocatorRef alloc, const UniChar *chars, CFIndex numChars); + + +/* These functions try not to copy the provided buffer. The buffer will be deallocated +with the provided contentsDeallocator when it's no longer needed; to not free +the buffer, specify kCFAllocatorNull here. As usual, NULL means default allocator. + +NOTE: Do not count on these buffers as being used by the string; +in some cases the CFString might free the buffer and use something else +(for instance if it decides to always use Unicode encoding internally). + +NOTE: If you are not transferring ownership of the buffer to the CFString +(for instance, you supplied contentsDeallocator = kCFAllocatorNull), it is your +responsibility to assure the buffer does not go away during the lifetime of the string. +If the string is retained or copied, its lifetime might extend in ways you cannot +predict. So, for strings created with buffers whose lifetimes you cannot +guarantee, you need to be extremely careful --- do not hand it out to any +APIs which might retain or copy the strings. +*/ +CF_EXPORT +CFStringRef CFStringCreateWithPascalStringNoCopy(CFAllocatorRef alloc, ConstStr255Param pStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator); + +CF_EXPORT +CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator); + +/* The following takes an explicit length, and allows you to specify whether the data is an external format --- that is, whether to pay attention to the BOM character (if any) and do byte swapping if necessary +*/ +CF_EXPORT +CFStringRef CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalRepresentation, CFAllocatorRef contentsDeallocator); + +CF_EXPORT +CFStringRef CFStringCreateWithCharactersNoCopy(CFAllocatorRef alloc, const UniChar *chars, CFIndex numChars, CFAllocatorRef contentsDeallocator); + +/* Create copies of part or all of the string. +*/ +CF_EXPORT +CFStringRef CFStringCreateWithSubstring(CFAllocatorRef alloc, CFStringRef str, CFRange range); + +CF_EXPORT +CFStringRef CFStringCreateCopy(CFAllocatorRef alloc, CFStringRef theString); + +/* These functions create a CFString from the provided printf-like format string and arguments. +*/ +CF_EXPORT +CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...) CF_FORMAT_FUNCTION(3,4); + +CF_EXPORT +CFStringRef CFStringCreateWithFormatAndArguments(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments) CF_FORMAT_FUNCTION(3,0); + +/* Functions to create mutable strings. "maxLength", if not 0, is a hard bound on the length of the string. If 0, there is no limit on the length. +*/ +CF_EXPORT +CFMutableStringRef CFStringCreateMutable(CFAllocatorRef alloc, CFIndex maxLength); + +CF_EXPORT +CFMutableStringRef CFStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFStringRef theString); + +/* This function creates a mutable string that has a developer supplied and directly editable backing store. +The string will be manipulated within the provided buffer (if any) until it outgrows capacity; then the +externalCharactersAllocator will be consulted for more memory. When the CFString is deallocated, the +buffer will be freed with the externalCharactersAllocator. Provide kCFAllocatorNull here to prevent the buffer +from ever being reallocated or deallocated by CFString. See comments at top of this file for more info. +*/ +CF_EXPORT +CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy(CFAllocatorRef alloc, UniChar *chars, CFIndex numChars, CFIndex capacity, CFAllocatorRef externalCharactersAllocator); + +/*** Basic accessors for the contents ***/ + +/* Number of 16-bit Unicode characters in the string. +*/ +CF_EXPORT +CFIndex CFStringGetLength(CFStringRef theString); + +/* Extracting the contents of the string. For obtaining multiple characters, calling +CFStringGetCharacters() is more efficient than multiple calls to CFStringGetCharacterAtIndex(). +If the length of the string is not known (so you can't use a fixed size buffer for CFStringGetCharacters()), +another method is to use is CFStringGetCharacterFromInlineBuffer() (see further below). +*/ +CF_EXPORT +UniChar CFStringGetCharacterAtIndex(CFStringRef theString, CFIndex idx); + +CF_EXPORT +void CFStringGetCharacters(CFStringRef theString, CFRange range, UniChar *buffer); + + +/*** Conversion to other encodings ***/ + +/* These two convert into the provided buffer; they return false if conversion isn't possible +(due to conversion error, or not enough space in the provided buffer). +These functions do zero-terminate or put the length byte; the provided bufferSize should include +space for this (so pass 256 for Str255). More sophisticated usages can go through CFStringGetBytes(). +These functions are equivalent to calling CFStringGetBytes() with +the range of the string; lossByte = 0; and isExternalRepresentation = false; +if successful, they then insert the leading length or terminating zero, as desired. +*/ +CF_EXPORT +Boolean CFStringGetPascalString(CFStringRef theString, StringPtr buffer, CFIndex bufferSize, CFStringEncoding encoding); + +CF_EXPORT +Boolean CFStringGetCString(CFStringRef theString, char *buffer, CFIndex bufferSize, CFStringEncoding encoding); + +/* These functions attempt to return in O(1) time the desired format for the string. +Note that although this means a pointer to the internal structure is being returned, +this can't always be counted on. Please see note at the top of the file for more +details. +*/ +CF_EXPORT +ConstStringPtr CFStringGetPascalStringPtr(CFStringRef theString, CFStringEncoding encoding); /* May return NULL at any time; be prepared for NULL */ + +CF_EXPORT +const char *CFStringGetCStringPtr(CFStringRef theString, CFStringEncoding encoding); /* May return NULL at any time; be prepared for NULL */ + +CF_EXPORT +const UniChar *CFStringGetCharactersPtr(CFStringRef theString); /* May return NULL at any time; be prepared for NULL */ + +/* The primitive conversion routine; allows you to convert a string piece at a time + into a fixed size buffer. Returns number of characters converted. + Characters that cannot be converted to the specified encoding are represented + with the byte specified by lossByte; if lossByte is 0, then lossy conversion + is not allowed and conversion stops, returning partial results. + Pass buffer==NULL if you don't care about the converted string (but just the convertability, + or number of bytes required). + maxBufLength indicates the maximum number of bytes to generate. It is ignored when buffer==NULL. + Does not zero-terminate. If you want to create Pascal or C string, allow one extra byte at start or end. + Setting isExternalRepresentation causes any extra bytes that would allow + the data to be made persistent to be included; for instance, the Unicode BOM. Note that + CFString prepends UTF encoded data with the Unicode BOM + when generating external representation if the target encoding allows. It's important to note that + only UTF-8, UTF-16, and UTF-32 define the handling of the byte order mark character, and the "LE" + and "BE" variants of UTF-16 and UTF-32 don't. +*/ +CF_EXPORT +CFIndex CFStringGetBytes(CFStringRef theString, CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, UInt8 *buffer, CFIndex maxBufLen, CFIndex *usedBufLen); + +/* Convenience functions String <-> Data. These generate "external" formats, that is, formats that + can be written out to disk. For instance, if the encoding is Unicode, + CFStringCreateFromExternalRepresentation() pays attention to the BOM character (if any) + and does byte swapping if necessary. Similarly CFStringCreateExternalRepresentation() will + include a BOM character if appropriate. See CFStringGetBytes() for more on this and lossByte. +*/ +CF_EXPORT +CFStringRef CFStringCreateFromExternalRepresentation(CFAllocatorRef alloc, CFDataRef data, CFStringEncoding encoding); /* May return NULL on conversion error */ + +CF_EXPORT +CFDataRef CFStringCreateExternalRepresentation(CFAllocatorRef alloc, CFStringRef theString, CFStringEncoding encoding, UInt8 lossByte); /* May return NULL on conversion error */ + +/* Hints about the contents of a string +*/ +CF_EXPORT +CFStringEncoding CFStringGetSmallestEncoding(CFStringRef theString); /* Result in O(n) time max */ + +CF_EXPORT +CFStringEncoding CFStringGetFastestEncoding(CFStringRef theString); /* Result in O(1) time max */ + +/* General encoding info +*/ +CF_EXPORT +CFStringEncoding CFStringGetSystemEncoding(void); /* The default encoding for the system; untagged 8-bit characters are usually in this encoding */ + +CF_EXPORT +CFIndex CFStringGetMaximumSizeForEncoding(CFIndex length, CFStringEncoding encoding); /* Max bytes a string of specified length (in UniChars) will take up if encoded */ + + +/*** FileSystem path conversion functions ***/ + +/* Extract the contents of the string as a NULL-terminated 8-bit string appropriate for passing to POSIX APIs (for example, normalized for HFS+). The string is zero-terminated. false will be returned if the conversion results don't fit into the buffer. Use CFStringGetMaximumSizeOfFileSystemRepresentation() if you want to make sure the buffer is of sufficient length. +*/ +CF_EXPORT +Boolean CFStringGetFileSystemRepresentation(CFStringRef string, char *buffer, CFIndex maxBufLen); + +/* Get the upper bound on the number of bytes required to hold the file system representation for the string. This result is returned quickly as a very rough approximation, and could be much larger than the actual space required. The result includes space for the zero termination. If you are allocating a buffer for long-term keeping, it's recommended that you reallocate it smaller (to be the right size) after calling CFStringGetFileSystemRepresentation(). +*/ +CF_EXPORT +CFIndex CFStringGetMaximumSizeOfFileSystemRepresentation(CFStringRef string); + +/* Create a CFString from the specified zero-terminated POSIX file system representation. If the conversion fails (possible due to bytes in the buffer not being a valid sequence of bytes for the appropriate character encoding), NULL is returned. +*/ +CF_EXPORT +CFStringRef CFStringCreateWithFileSystemRepresentation(CFAllocatorRef alloc, const char *buffer); + + +/*** Comparison functions. ***/ + +/* Find and compare flags; these are OR'ed together and provided as CFStringCompareFlags in the various functions. +*/ +typedef CF_OPTIONS(CFOptionFlags, CFStringCompareFlags) { + kCFCompareCaseInsensitive = 1, + kCFCompareBackwards = 4, /* Starting from the end of the string */ + kCFCompareAnchored = 8, /* Only at the specified starting point */ + kCFCompareNonliteral = 16, /* If specified, loose equivalence is performed (o-umlaut == o, umlaut) */ + kCFCompareLocalized = 32, /* User's default locale is used for the comparisons */ + kCFCompareNumerically = 64, /* Numeric comparison is used; that is, Foo2.txt < Foo7.txt < Foo25.txt */ + kCFCompareDiacriticInsensitive CF_ENUM_AVAILABLE(10_5, 2_0) = 128, /* If specified, ignores diacritics (o-umlaut == o) */ + kCFCompareWidthInsensitive CF_ENUM_AVAILABLE(10_5, 2_0) = 256, /* If specified, ignores width differences ('a' == UFF41) */ + kCFCompareForcedOrdering CF_ENUM_AVAILABLE(10_5, 2_0) = 512 /* If specified, comparisons are forced to return either kCFCompareLessThan or kCFCompareGreaterThan if the strings are equivalent but not strictly equal, for stability when sorting (e.g. "aaa" > "AAA" with kCFCompareCaseInsensitive specified) */ +}; + +/* The main comparison routine; compares specified range of the first string to (the full range of) the second string. + locale == NULL indicates canonical locale (the return value from CFLocaleGetSystem()). + kCFCompareNumerically, added in 10.2, does not work if kCFCompareLocalized is specified on systems before 10.3 + kCFCompareBackwards and kCFCompareAnchored are not applicable. + rangeToCompare applies to the first string; that is, only the substring of theString1 specified by rangeToCompare is compared against all of theString2. +*/ +CF_EXPORT +CFComparisonResult CFStringCompareWithOptionsAndLocale(CFStringRef theString1, CFStringRef theString2, CFRange rangeToCompare, CFStringCompareFlags compareOptions, CFLocaleRef locale) CF_AVAILABLE(10_5, 2_0); + +/* Comparison convenience. Uses the current user locale (the return value from CFLocaleCopyCurrent()) if kCFCompareLocalized. Refer to CFStringCompareWithOptionsAndLocale() for more info. +*/ +CF_EXPORT +CFComparisonResult CFStringCompareWithOptions(CFStringRef theString1, CFStringRef theString2, CFRange rangeToCompare, CFStringCompareFlags compareOptions); + +/* Comparison convenience suitable for passing as sorting functions. + kCFCompareNumerically, added in 10.2, does not work if kCFCompareLocalized is specified on systems before 10.3 + kCFCompareBackwards and kCFCompareAnchored are not applicable. +*/ +CF_EXPORT +CFComparisonResult CFStringCompare(CFStringRef theString1, CFStringRef theString2, CFStringCompareFlags compareOptions); + +/* CFStringFindWithOptionsAndLocale() returns the found range in the CFRange * argument; you can pass NULL for simple discovery check. + locale == NULL indicates canonical locale (the return value from CFLocaleGetSystem()). + If stringToFind is the empty string (zero length), nothing is found. + Ignores the kCFCompareNumerically option. + Only the substring of theString specified by rangeToSearch is searched for stringToFind. +*/ +CF_EXPORT +Boolean CFStringFindWithOptionsAndLocale(CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFStringCompareFlags searchOptions, CFLocaleRef locale, CFRange *result) CF_AVAILABLE(10_5, 2_0); + +/* Find convenience. Uses the current user locale (the return value from CFLocaleCopyCurrent()) if kCFCompareLocalized. Refer to CFStringFindWithOptionsAndLocale() for more info. +*/ +CF_EXPORT +Boolean CFStringFindWithOptions(CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFStringCompareFlags searchOptions, CFRange *result); + +/* CFStringCreateArrayWithFindResults() returns an array of CFRange pointers, or NULL if there are no matches. + Overlapping instances are not found; so looking for "AA" in "AAA" finds just one range. + Post 10.1: If kCFCompareBackwards is provided, the scan is done from the end (which can give a different result), and + the results are stored in the array backwards (last found range in slot 0). + If stringToFind is the empty string (zero length), nothing is found. + kCFCompareAnchored causes just the consecutive instances at start (or end, if kCFCompareBackwards) to be reported. So, searching for "AB" in "ABABXAB..." you just get the first two occurrences. + Ignores the kCFCompareNumerically option. + Only the substring of theString specified by rangeToSearch is searched for stringToFind. +*/ +CF_EXPORT +CFArrayRef CFStringCreateArrayWithFindResults(CFAllocatorRef alloc, CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFStringCompareFlags compareOptions); + +/* Find conveniences; see comments above concerning empty string and options. +*/ +CF_EXPORT +CFRange CFStringFind(CFStringRef theString, CFStringRef stringToFind, CFStringCompareFlags compareOptions); + +CF_EXPORT +Boolean CFStringHasPrefix(CFStringRef theString, CFStringRef prefix); + +CF_EXPORT +Boolean CFStringHasSuffix(CFStringRef theString, CFStringRef suffix); + +/*! + @function CFStringGetRangeOfComposedCharactersAtIndex + Returns the range of the composed character sequence at the specified index. + @param theString The CFString which is to be searched. If this + parameter is not a valid CFString, the behavior is + undefined. + @param theIndex The index of the character contained in the + composed character sequence. If the index is + outside the index space of the string (0 to N-1 inclusive, + where N is the length of the string), the behavior is + undefined. + @result The range of the composed character sequence. +*/ +CF_EXPORT CFRange CFStringGetRangeOfComposedCharactersAtIndex(CFStringRef theString, CFIndex theIndex); + +/*! + @function CFStringFindCharacterFromSet + Query the range of the first character contained in the specified character set. + @param theString The CFString which is to be searched. If this + parameter is not a valid CFString, the behavior is + undefined. + @param theSet The CFCharacterSet against which the membership + of characters is checked. If this parameter is not a valid + CFCharacterSet, the behavior is undefined. + @param range The range of characters within the string to search. If + the range location or end point (defined by the location + plus length minus 1) are outside the index space of the + string (0 to N-1 inclusive, where N is the length of the + string), the behavior is undefined. If the range length is + negative, the behavior is undefined. The range may be empty + (length 0), in which case no search is performed. + @param searchOptions The bitwise-or'ed option flags to control + the search behavior. The supported options are + kCFCompareBackwards andkCFCompareAnchored. + If other option flags are specified, the behavior + is undefined. + @param result The pointer to a CFRange supplied by the caller in + which the search result is stored. Note that the length + of this range can be more than 1, if for instance the + result is a composed character. If a pointer to an invalid + memory is specified, the behavior is undefined. + @result true, if at least a character which is a member of the character + set is found and result is filled, otherwise, false. +*/ +CF_EXPORT Boolean CFStringFindCharacterFromSet(CFStringRef theString, CFCharacterSetRef theSet, CFRange rangeToSearch, CFStringCompareFlags searchOptions, CFRange *result); + +/* Find range of bounds of the line(s) that span the indicated range (startIndex, numChars), + taking into account various possible line separator sequences (CR, CRLF, LF, and Unicode NextLine, LineSeparator, ParagraphSeparator). + All return values are "optional" (provide NULL if you don't want them) + lineBeginIndex: index of first character in line + lineEndIndex: index of first character of the next line (including terminating line separator characters) + contentsEndIndex: index of the first line separator character + Thus, lineEndIndex - lineBeginIndex is the number of chars in the line, including the line separators + contentsEndIndex - lineBeginIndex is the number of chars in the line w/out the line separators +*/ +CF_EXPORT +void CFStringGetLineBounds(CFStringRef theString, CFRange range, CFIndex *lineBeginIndex, CFIndex *lineEndIndex, CFIndex *contentsEndIndex); + +/* Same as CFStringGetLineBounds(), however, will only look for paragraphs. Won't stop at Unicode NextLine or LineSeparator characters. +*/ +CF_EXPORT +void CFStringGetParagraphBounds(CFStringRef string, CFRange range, CFIndex *parBeginIndex, CFIndex *parEndIndex, CFIndex *contentsEndIndex) CF_AVAILABLE(10_5, 2_0); + +/*! + @function CFStringGetHyphenationLocationBeforeIndex + Retrieve the first potential hyphenation location found before the specified location. + @param string The CFString which is to be hyphenated. If this + parameter is not a valid CFString, the behavior is + undefined. + @param location An index in the string. If a valid hyphen index is returned, it + will be before this index. + @param limitRange The range of characters within the string to search. If + the range location or end point (defined by the location + plus length minus 1) are outside the index space of the + string (0 to N-1 inclusive, where N is the length of the + string), the behavior is undefined. If the range length is + negative, the behavior is undefined. The range may be empty + (length 0), in which case no hyphen location is generated. + @param options Reserved for future use. + @param locale Specifies which language's hyphenation conventions to use. + This must be a valid locale. Hyphenation data is not available + for all locales. You can use CFStringIsHyphenationAvailableForLocale + to test for availability of hyphenation data. + @param character The suggested hyphen character to insert. Pass NULL if you + do not need this information. + @result an index in the string where it is appropriate to insert a hyphen, if + one exists; else kCFNotFound +*/ +CF_EXPORT +CFIndex CFStringGetHyphenationLocationBeforeIndex(CFStringRef string, CFIndex location, CFRange limitRange, CFOptionFlags options, CFLocaleRef locale, UTF32Char *character) CF_AVAILABLE(10_7, 4_2); + +CF_EXPORT +Boolean CFStringIsHyphenationAvailableForLocale(CFLocaleRef locale) CF_AVAILABLE(10_7, 4_3); + +/*** Exploding and joining strings with a separator string ***/ + +CF_EXPORT +CFStringRef CFStringCreateByCombiningStrings(CFAllocatorRef alloc, CFArrayRef theArray, CFStringRef separatorString); /* Empty array returns empty string; one element array returns the element */ + +CF_EXPORT +CFArrayRef CFStringCreateArrayBySeparatingStrings(CFAllocatorRef alloc, CFStringRef theString, CFStringRef separatorString); /* No separators in the string returns array with that string; string == sep returns two empty strings */ + + +/*** Parsing non-localized numbers from strings ***/ + +CF_EXPORT +SInt32 CFStringGetIntValue(CFStringRef str); /* Skips whitespace; returns 0 on error, MAX or -MAX on overflow */ + +CF_EXPORT +double CFStringGetDoubleValue(CFStringRef str); /* Skips whitespace; returns 0.0 on error */ + + +/*** MutableString functions ***/ + +/* CFStringAppend("abcdef", "xxxxx") -> "abcdefxxxxx" + CFStringDelete("abcdef", CFRangeMake(2, 3)) -> "abf" + CFStringReplace("abcdef", CFRangeMake(2, 3), "xxxxx") -> "abxxxxxf" + CFStringReplaceAll("abcdef", "xxxxx") -> "xxxxx" +*/ +CF_EXPORT +void CFStringAppend(CFMutableStringRef theString, CFStringRef appendedString); + +CF_EXPORT +void CFStringAppendCharacters(CFMutableStringRef theString, const UniChar *chars, CFIndex numChars); + +CF_EXPORT +void CFStringAppendPascalString(CFMutableStringRef theString, ConstStr255Param pStr, CFStringEncoding encoding); + +CF_EXPORT +void CFStringAppendCString(CFMutableStringRef theString, const char *cStr, CFStringEncoding encoding); + +CF_EXPORT +void CFStringAppendFormat(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, ...) CF_FORMAT_FUNCTION(3,4); + +CF_EXPORT +void CFStringAppendFormatAndArguments(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments) CF_FORMAT_FUNCTION(3,0); + +CF_EXPORT +void CFStringInsert(CFMutableStringRef str, CFIndex idx, CFStringRef insertedStr); + +CF_EXPORT +void CFStringDelete(CFMutableStringRef theString, CFRange range); + +CF_EXPORT +void CFStringReplace(CFMutableStringRef theString, CFRange range, CFStringRef replacement); + +CF_EXPORT +void CFStringReplaceAll(CFMutableStringRef theString, CFStringRef replacement); /* Replaces whole string */ + +/* Replace all occurrences of target in rangeToSearch of theString with replacement. + Pays attention to kCFCompareCaseInsensitive, kCFCompareBackwards, kCFCompareNonliteral, and kCFCompareAnchored. + kCFCompareBackwards can be used to do the replacement starting from the end, which could give a different result. + ex. AAAAA, replace AA with B -> BBA or ABB; latter if kCFCompareBackwards + kCFCompareAnchored assures only anchored but multiple instances are found (the instances must be consecutive at start or end) + ex. AAXAA, replace A with B -> BBXBB or BBXAA; latter if kCFCompareAnchored + Returns number of replacements performed. +*/ +CF_EXPORT +CFIndex CFStringFindAndReplace(CFMutableStringRef theString, CFStringRef stringToFind, CFStringRef replacementString, CFRange rangeToSearch, CFStringCompareFlags compareOptions); + + +/* This function will make the contents of a mutable CFString point directly at the specified UniChar array. + It works only with CFStrings created with CFStringCreateMutableWithExternalCharactersNoCopy(). + This function does not free the previous buffer. + The string will be manipulated within the provided buffer (if any) until it outgrows capacity; then the + externalCharactersAllocator will be consulted for more memory. + See comments at the top of this file for more info. +*/ +CF_EXPORT +void CFStringSetExternalCharactersNoCopy(CFMutableStringRef theString, UniChar *chars, CFIndex length, CFIndex capacity); /* Works only on specially created mutable strings! */ + +/* CFStringPad() will pad or cut down a string to the specified size. + The pad string is used as the fill string; indexIntoPad specifies which character to start with. + CFStringPad("abc", " ", 9, 0) -> "abc " + CFStringPad("abc", ". ", 9, 1) -> "abc . . ." + CFStringPad("abcdef", ?, 3, ?) -> "abc" + + CFStringTrim() will trim the specified string from both ends of the string. + CFStringTrimWhitespace() will do the same with white space characters (tab, newline, etc) + CFStringTrim(" abc ", " ") -> "abc" + CFStringTrim("* * * *abc * ", "* ") -> "*abc " +*/ +CF_EXPORT +void CFStringPad(CFMutableStringRef theString, CFStringRef padString, CFIndex length, CFIndex indexIntoPad); + +CF_EXPORT +void CFStringTrim(CFMutableStringRef theString, CFStringRef trimString); + +CF_EXPORT +void CFStringTrimWhitespace(CFMutableStringRef theString); + +CF_EXPORT +void CFStringLowercase(CFMutableStringRef theString, CFLocaleRef locale); + +CF_EXPORT +void CFStringUppercase(CFMutableStringRef theString, CFLocaleRef locale); + +CF_EXPORT +void CFStringCapitalize(CFMutableStringRef theString, CFLocaleRef locale); + +/*! + @typedef CFStringNormalizationForm + This is the type of Unicode normalization forms as described in + Unicode Technical Report #15. To normalize for use with file + system calls, use CFStringGetFileSystemRepresentation(). +*/ +typedef CF_ENUM(CFIndex, CFStringNormalizationForm) { + kCFStringNormalizationFormD = 0, // Canonical Decomposition + kCFStringNormalizationFormKD, // Compatibility Decomposition + kCFStringNormalizationFormC, // Canonical Decomposition followed by Canonical Composition + kCFStringNormalizationFormKC // Compatibility Decomposition followed by Canonical Composition +}; + +/*! + @function CFStringNormalize + Normalizes the string into the specified form as described in + Unicode Technical Report #15. + @param theString The string which is to be normalized. If this + parameter is not a valid mutable CFString, the behavior is + undefined. + @param theForm The form into which the string is to be normalized. + If this parameter is not a valid CFStringNormalizationForm value, + the behavior is undefined. +*/ +CF_EXPORT void CFStringNormalize(CFMutableStringRef theString, CFStringNormalizationForm theForm); + + +/*! + @function CFStringFold + Folds the string into the form specified by the flags. + Character foldings are operations that convert any of a set of characters + sharing similar semantics into a single representative from that set. + This function can be used to preprocess strings that are to be compared, + searched, or indexed. + Note that folding does not include normalization, so it is necessary + to use CFStringNormalize in addition to CFStringFold in order to obtain + the effect of kCFCompareNonliteral. + @param theString The string which is to be folded. If this parameter is not + a valid mutable CFString, the behavior is undefined. + @param theFlag The equivalency flags which describes the character folding form. + Only those flags containing the word "insensitive" are recognized here; other flags are ignored. + Folding with kCFCompareCaseInsensitive removes case distinctions in accordance with the mapping + specified by ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt. Folding with + kCFCompareDiacriticInsensitive removes distinctions of accents and other diacritics. Folding + with kCFCompareWidthInsensitive removes character width distinctions by mapping characters in + the range U+FF00-U+FFEF to their ordinary equivalents. + @param theLocale The locale tailoring the character folding behavior. If NULL, + it's considered to be the system locale returned from CFLocaleGetSystem(). + If non-NULL and not a valid CFLocale object, the behavior is undefined. +*/ + +CF_EXPORT +void CFStringFold(CFMutableStringRef theString, CFStringCompareFlags theFlags, CFLocaleRef theLocale) CF_AVAILABLE(10_5, 2_0); + +/* Perform string transliteration. The transformation represented by transform is applied to the given range of string, modifying it in place. Only the specified range will be modified, but the transform may look at portions of the string outside that range for context. NULL range pointer causes the whole string to be transformed. On return, range is modified to reflect the new range corresponding to the original range. reverse indicates that the inverse transform should be used instead, if it exists. If the transform is successful, true is returned; if unsuccessful, false. Reasons for the transform being unsuccessful include an invalid transform identifier, or attempting to reverse an irreversible transform. + +You can pass one of the predefined transforms below, or any valid ICU transform ID as defined in the ICU User Guide. Note that we do not support arbitrary set of ICU transform rules. +*/ +CF_EXPORT +Boolean CFStringTransform(CFMutableStringRef string, CFRange *range, CFStringRef transform, Boolean reverse); + +/* Transform identifiers for CFStringTransform() +*/ +CF_EXPORT const CFStringRef kCFStringTransformStripCombiningMarks; +CF_EXPORT const CFStringRef kCFStringTransformToLatin; +CF_EXPORT const CFStringRef kCFStringTransformFullwidthHalfwidth; +CF_EXPORT const CFStringRef kCFStringTransformLatinKatakana; +CF_EXPORT const CFStringRef kCFStringTransformLatinHiragana; +CF_EXPORT const CFStringRef kCFStringTransformHiraganaKatakana; +CF_EXPORT const CFStringRef kCFStringTransformMandarinLatin; +CF_EXPORT const CFStringRef kCFStringTransformLatinHangul; +CF_EXPORT const CFStringRef kCFStringTransformLatinArabic; +CF_EXPORT const CFStringRef kCFStringTransformLatinHebrew; +CF_EXPORT const CFStringRef kCFStringTransformLatinThai; +CF_EXPORT const CFStringRef kCFStringTransformLatinCyrillic; +CF_EXPORT const CFStringRef kCFStringTransformLatinGreek; +CF_EXPORT const CFStringRef kCFStringTransformToXMLHex; +CF_EXPORT const CFStringRef kCFStringTransformToUnicodeName; +CF_EXPORT const CFStringRef kCFStringTransformStripDiacritics CF_AVAILABLE(10_5, 2_0); + + +/*** General encoding related functionality ***/ + +/* This returns availability of the encoding on the system +*/ +CF_EXPORT +Boolean CFStringIsEncodingAvailable(CFStringEncoding encoding); + +/* This function returns list of available encodings. The returned list is terminated with kCFStringEncodingInvalidId and owned by the system. +*/ +CF_EXPORT +const CFStringEncoding *CFStringGetListOfAvailableEncodings(void); + +/* Returns name of the encoding; non-localized. +*/ +CF_EXPORT +CFStringRef CFStringGetNameOfEncoding(CFStringEncoding encoding); + +/* ID mapping functions from/to Cocoa NSStringEncoding. Returns kCFStringEncodingInvalidId if no mapping exists. +*/ +CF_EXPORT +unsigned long CFStringConvertEncodingToNSStringEncoding(CFStringEncoding encoding); + +CF_EXPORT +CFStringEncoding CFStringConvertNSStringEncodingToEncoding(unsigned long encoding); + +/* ID mapping functions from/to Microsoft Windows codepage (covers both OEM & ANSI). Returns kCFStringEncodingInvalidId if no mapping exists. +*/ +CF_EXPORT +UInt32 CFStringConvertEncodingToWindowsCodepage(CFStringEncoding encoding); + +CF_EXPORT +CFStringEncoding CFStringConvertWindowsCodepageToEncoding(UInt32 codepage); + +/* ID mapping functions from/to IANA registery charset names. Returns kCFStringEncodingInvalidId if no mapping exists. +*/ +CF_EXPORT +CFStringEncoding CFStringConvertIANACharSetNameToEncoding(CFStringRef theString); + +CF_EXPORT +CFStringRef CFStringConvertEncodingToIANACharSetName(CFStringEncoding encoding); + +/* Returns the most compatible MacOS script value for the input encoding */ +/* i.e. kCFStringEncodingMacRoman -> kCFStringEncodingMacRoman */ +/* kCFStringEncodingWindowsLatin1 -> kCFStringEncodingMacRoman */ +/* kCFStringEncodingISO_2022_JP -> kCFStringEncodingMacJapanese */ +CF_EXPORT +CFStringEncoding CFStringGetMostCompatibleMacStringEncoding(CFStringEncoding encoding); + + + +/* The next two functions allow fast access to the contents of a string, + assuming you are doing sequential or localized accesses. To use, call + CFStringInitInlineBuffer() with a CFStringInlineBuffer (on the stack, say), + and a range in the string to look at. Then call CFStringGetCharacterFromInlineBuffer() + as many times as you want, with a index into that range (relative to the start + of that range). These are INLINE functions and will end up calling CFString only + once in a while, to fill a buffer. CFStringGetCharacterFromInlineBuffer() returns 0 if + a location outside the original range is specified. +*/ +#define __kCFStringInlineBufferLength 64 +typedef struct { + UniChar buffer[__kCFStringInlineBufferLength]; + CFStringRef theString; + const UniChar *directUniCharBuffer; + const char *directCStringBuffer; + CFRange rangeToBuffer; /* Range in string to buffer */ + CFIndex bufferedRangeStart; /* Start of range currently buffered (relative to rangeToBuffer.location) */ + CFIndex bufferedRangeEnd; /* bufferedRangeStart + number of chars actually buffered */ +} CFStringInlineBuffer; + +#if defined(CF_INLINE) +CF_INLINE void CFStringInitInlineBuffer(CFStringRef str, CFStringInlineBuffer *buf, CFRange range) { + buf->theString = str; + buf->rangeToBuffer = range; + buf->directCStringBuffer = (buf->directUniCharBuffer = CFStringGetCharactersPtr(str)) ? NULL : CFStringGetCStringPtr(str, kCFStringEncodingASCII); + buf->bufferedRangeStart = buf->bufferedRangeEnd = 0; +} + +CF_INLINE UniChar CFStringGetCharacterFromInlineBuffer(CFStringInlineBuffer *buf, CFIndex idx) { + if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0; + if (buf->directUniCharBuffer) return buf->directUniCharBuffer[idx + buf->rangeToBuffer.location]; + if (buf->directCStringBuffer) return (UniChar)(buf->directCStringBuffer[idx + buf->rangeToBuffer.location]); + if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) { + if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0; + buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength; + if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length; + CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer); + } + return buf->buffer[idx - buf->bufferedRangeStart]; +} + +#else +/* If INLINE functions are not available, we do somewhat less powerful macros that work similarly (except be aware that the buf argument is evaluated multiple times). +*/ +#define CFStringInitInlineBuffer(str, buf, range) \ + do {(buf)->theString = str; (buf)->rangeToBuffer = range; (buf)->directCStringBuffer = ((buf)->directUniCharBuffer = CFStringGetCharactersPtr(str)) ? NULL : CFStringGetCStringPtr(str, kCFStringEncodingASCII);} while (0) + +#define CFStringGetCharacterFromInlineBuffer(buf, idx) \ + (((idx) < 0 || (idx) >= (buf)->rangeToBuffer.length) ? 0 : ((buf)->directUniCharBuffer ? (buf)->directUniCharBuffer[(idx) + (buf)->rangeToBuffer.location] : ((buf)->directCStringBuffer ? (UniChar)((buf)->directCStringBuffer[(idx) + (buf)->rangeToBuffer.location]) : CFStringGetCharacterAtIndex((buf)->theString, (idx) + (buf)->rangeToBuffer.location)))) + +#endif /* CF_INLINE */ + + + +/* UTF-16 surrogate support + */ +CF_INLINE Boolean CFStringIsSurrogateHighCharacter(UniChar character) { + return ((character >= 0xD800UL) && (character <= 0xDBFFUL) ? true : false); +} + +CF_INLINE Boolean CFStringIsSurrogateLowCharacter(UniChar character) { + return ((character >= 0xDC00UL) && (character <= 0xDFFFUL) ? true : false); +} + +CF_INLINE UTF32Char CFStringGetLongCharacterForSurrogatePair(UniChar surrogateHigh, UniChar surrogateLow) { + return (UTF32Char)(((surrogateHigh - 0xD800UL) << 10) + (surrogateLow - 0xDC00UL) + 0x0010000UL); +} + +// Maps a UTF-32 character to a pair of UTF-16 surrogate characters. The buffer pointed by surrogates has to have space for at least 2 UTF-16 characters. Returns true if mapped to a surrogate pair. +CF_INLINE Boolean CFStringGetSurrogatePairForLongCharacter(UTF32Char character, UniChar *surrogates) { + if ((character > 0xFFFFUL) && (character < 0x110000UL)) { // Non-BMP character + character -= 0x10000; + if (NULL != surrogates) { + surrogates[0] = (UniChar)((character >> 10) + 0xD800UL); + surrogates[1] = (UniChar)((character & 0x3FF) + 0xDC00UL); + } + return true; + } else { + if (NULL != surrogates) *surrogates = (UniChar)character; + return false; + } +} + +/* Rest of the stuff in this file is private and should not be used directly +*/ +/* For debugging only; output goes to stderr + Use CFShow() to printf the description of any CFType; + Use CFShowStr() to printf detailed info about a CFString +*/ +CF_EXPORT +void CFShow(CFTypeRef obj); + +CF_EXPORT +void CFShowStr(CFStringRef str); + +/* This function is private and should not be used directly */ +CF_EXPORT +CFStringRef __CFStringMakeConstantString(const char *cStr) CF_FORMAT_ARGUMENT(1); /* Private; do not use */ + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFSTRING__ */ diff --git a/include/CoreFoundation/CFStringDefaultEncoding.h b/include/CoreFoundation/CFStringDefaultEncoding.h new file mode 100644 index 0000000..46f811e --- /dev/null +++ b/include/CoreFoundation/CFStringDefaultEncoding.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFStringDefaultEncoding.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFSTRINGDEFAULTENCODING__) +#define __COREFOUNDATION_CFSTRINGDEFAULTENCODING__ 1 + +#include + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +#include +#include +#include +#include +#include +#include +#include +#include + +CF_EXTERN_C_BEGIN + +#define __kCFUserEncodingEnvVariableName ("__CF_USER_TEXT_ENCODING") +#define __kCFMaxDefaultEncodingFileLength (64) +#define __kCFUserEncodingFileName ("/.CFUserTextEncoding") + +CF_EXPORT void _CFStringGetUserDefaultEncoding(UInt32 *oScriptValue, UInt32 *oRegionValue); +CF_EXPORT void _CFStringGetInstallationEncodingAndRegion(uint32_t *encoding, uint32_t *region); +CF_EXPORT Boolean _CFStringSaveUserDefaultEncoding(UInt32 iScriptValue, UInt32 iRegionValue); + +CF_INLINE void __CFStringGetUserDefaultEncoding(UInt32 *oScriptValue, UInt32 *oRegionValue) { _CFStringGetUserDefaultEncoding(oScriptValue, oRegionValue); } +CF_INLINE void __CFStringGetInstallationEncodingAndRegion(uint32_t *encoding, uint32_t *region) { _CFStringGetInstallationEncodingAndRegion(encoding, region); } +CF_INLINE void __CFStringSaveUserDefaultEncoding(UInt32 iScriptValue, UInt32 iRegionValue) { _CFStringSaveUserDefaultEncoding(iScriptValue, iRegionValue); } + +CF_EXTERN_C_END + +#endif + +#endif /* ! __COREFOUNDATION_CFSTRINGDEFAULTENCODING__ */ + + diff --git a/include/CoreFoundation/CFStringEncodingConverter.h b/include/CoreFoundation/CFStringEncodingConverter.h new file mode 100644 index 0000000..0275be0 --- /dev/null +++ b/include/CoreFoundation/CFStringEncodingConverter.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFStringEncodingConverter.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERTER__) +#define __COREFOUNDATION_CFSTRINGENCODINGCONVERTER__ 1 + +#include + + +CF_EXTERN_C_BEGIN + +/* Values for flags argument for the conversion functions below. These can be combined, but the three NonSpacing behavior flags are exclusive. +*/ +// kCFStringEncodingBasicDirectionLeftToRight ~ kCFStringEncodingPrependBOM will probably be deprecated and superceded by kCFStringEncodingPartialInput flag +enum { + kCFStringEncodingAllowLossyConversion = (1UL << 0), // Uses fallback functions to substitutes non mappable chars + kCFStringEncodingBasicDirectionLeftToRight = (1UL << 1), // Converted with original direction left-to-right. + kCFStringEncodingBasicDirectionRightToLeft = (1UL << 2), // Converted with original direction right-to-left. + kCFStringEncodingSubstituteCombinings = (1UL << 3), // Uses fallback function to combining chars. + kCFStringEncodingComposeCombinings = (1UL << 4), // Checks mappable precomposed equivalents for decomposed sequences. This is the default behavior. + kCFStringEncodingIgnoreCombinings = (1UL << 5), // Ignores combining chars. + kCFStringEncodingUseCanonical = (1UL << 6), // Always use canonical form + kCFStringEncodingUseHFSPlusCanonical = (1UL << 7), // Always use canonical form but leaves 0x2000 ranges + kCFStringEncodingPrependBOM = (1UL << 8), // Prepend BOM sequence (i.e. ISO2022KR) + kCFStringEncodingDisableCorporateArea = (1UL << 9), // Disable the usage of 0xF8xx area for Apple proprietary chars in converting to UniChar, resulting loosely mapping. + kCFStringEncodingASCIICompatibleConversion = (1UL << 10), // This flag forces strict ASCII compatible converion. i.e. MacJapanese 0x5C maps to Unicode 0x5C. + kCFStringEncodingLenientUTF8Conversion = (1UL << 11), // 10.1 (Puma) compatible lenient UTF-8 conversion. + kCFStringEncodingPartialInput = (1UL << 12), // input buffer is a part of stream + kCFStringEncodingPartialOutput = (1UL << 13) // output buffer streaming +}; + +/* Return values for CFStringEncodingUnicodeToBytes & CFStringEncodingBytesToUnicode functions +*/ +enum { + kCFStringEncodingConversionSuccess = 0, + kCFStringEncodingInvalidInputStream = 1, + kCFStringEncodingInsufficientOutputBufferLength = 2, + kCFStringEncodingConverterUnavailable = 3 +}; + +/* Macro to shift lossByte argument. +*/ +#define CFStringEncodingLossyByteToMask(lossByte) ((uint32_t)(lossByte << 24)|kCFStringEncodingAllowLossyConversion) +#define CFStringEncodingMaskToLossyByte(flags) ((uint8_t)(flags >> 24)) + +/* Macros for streaming support + */ +#define CFStringEncodingStreamIDMask (0x00FF0000) +#define CFStringEncodingStreamIDFromMask(mask) ((mask >> 16) & 0xFF) +#define CFStringEncodingStreamIDToMask(identifier) ((uint32_t)((identifier & 0xFF) << 16)) + +/* Converts characters into the specified encoding. Returns the constants defined above. +If maxByteLen is 0, bytes is ignored. You can pass lossyByte by passing the value in flags argument. +i.e. CFStringEncodingUnicodeToBytes(encoding, CFStringEncodingLossyByteToMask(lossByte), ....) +*/ +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); + +/* Converts bytes in the specified encoding into unicode. Returns the constants defined above. +maxCharLen & usdCharLen are in UniChar length, not byte length. +If maxCharLen is 0, characters is ignored. +*/ +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); + +/* Fallback functions used when allowLossy +*/ +typedef CFIndex (*CFStringEncodingToBytesFallbackProc)(const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); +typedef CFIndex (*CFStringEncodingToUnicodeFallbackProc)(const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); + +CF_EXPORT bool CFStringEncodingIsValidEncoding(uint32_t encoding); + +/* Returns kCFStringEncodingInvalidId terminated encoding list +*/ +CF_EXPORT const CFStringEncoding *CFStringEncodingListOfAvailableEncodings(void); + +/* Returns required length of destination buffer for conversion. These functions are faster than specifying 0 to maxByteLen (maxCharLen), but unnecessarily optimal length +*/ +CF_EXPORT CFIndex CFStringEncodingCharLengthForBytes(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes); +CF_EXPORT CFIndex CFStringEncodingByteLengthForCharacters(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars); + +/* Can register functions used for lossy conversion. Reregisters default procs if NULL +*/ +CF_EXPORT void CFStringEncodingRegisterFallbackProcedures(uint32_t encoding, CFStringEncodingToBytesFallbackProc toBytes, CFStringEncodingToUnicodeFallbackProc toUnicode); + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERTER__ */ + diff --git a/include/CoreFoundation/CFStringEncodingConverterExt.h b/include/CoreFoundation/CFStringEncodingConverterExt.h new file mode 100644 index 0000000..1072e43 --- /dev/null +++ b/include/CoreFoundation/CFStringEncodingConverterExt.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFStringEncodingConverterExt.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__) +#define __COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__ 1 + +#include + +CF_EXTERN_C_BEGIN + +#define MAX_DECOMPOSED_LENGTH (10) + +enum { + kCFStringEncodingConverterStandard = 0, + kCFStringEncodingConverterCheapEightBit = 1, + kCFStringEncodingConverterStandardEightBit = 2, + kCFStringEncodingConverterCheapMultiByte = 3, + kCFStringEncodingConverterPlatformSpecific = 4, // Other fields are ignored + kCFStringEncodingConverterICU = 5 // Other fields are ignored +}; + +/* kCFStringEncodingConverterStandard */ +typedef CFIndex (*CFStringEncodingToBytesProc)(uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); +typedef CFIndex (*CFStringEncodingToUnicodeProc)(uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); +/* kCFStringEncodingConverterCheapEightBit */ +typedef bool (*CFStringEncodingCheapEightBitToBytesProc)(uint32_t flags, UniChar character, uint8_t *byte); +typedef bool (*CFStringEncodingCheapEightBitToUnicodeProc)(uint32_t flags, uint8_t byte, UniChar *character); +/* kCFStringEncodingConverterStandardEightBit */ +typedef uint16_t (*CFStringEncodingStandardEightBitToBytesProc)(uint32_t flags, const UniChar *characters, CFIndex numChars, uint8_t *byte); +typedef uint16_t (*CFStringEncodingStandardEightBitToUnicodeProc)(uint32_t flags, uint8_t byte, UniChar *characters); +/* kCFStringEncodingConverterCheapMultiByte */ +typedef uint16_t (*CFStringEncodingCheapMultiByteToBytesProc)(uint32_t flags, UniChar character, uint8_t *bytes); +typedef uint16_t (*CFStringEncodingCheapMultiByteToUnicodeProc)(uint32_t flags, const uint8_t *bytes, CFIndex numBytes, UniChar *character); + +typedef CFIndex (*CFStringEncodingToBytesLenProc)(uint32_t flags, const UniChar *characters, CFIndex numChars); +typedef CFIndex (*CFStringEncodingToUnicodeLenProc)(uint32_t flags, const uint8_t *bytes, CFIndex numBytes); + +typedef CFIndex (*CFStringEncodingToBytesPrecomposeProc)(uint32_t flags, const UniChar *character, CFIndex numChars, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); +typedef bool (*CFStringEncodingIsValidCombiningCharacterProc)(UniChar character); + +typedef struct { + void *toBytes; + void *toUnicode; + uint16_t maxBytesPerChar; + uint16_t maxDecomposedCharLen; + uint8_t encodingClass; + uint32_t :24; + CFStringEncodingToBytesLenProc toBytesLen; + CFStringEncodingToUnicodeLenProc toUnicodeLen; + CFStringEncodingToBytesFallbackProc toBytesFallback; + CFStringEncodingToUnicodeFallbackProc toUnicodeFallback; + CFStringEncodingToBytesPrecomposeProc toBytesPrecompose; + CFStringEncodingIsValidCombiningCharacterProc isValidCombiningChar; +} CFStringEncodingConverter; + +extern const CFStringEncodingConverter *CFStringEncodingGetConverter(uint32_t encoding); + +enum { + kCFStringEncodingGetConverterSelector = 0, + kCFStringEncodingIsDecomposableCharacterSelector = 1, + kCFStringEncodingDecomposeCharacterSelector = 2, + kCFStringEncodingIsValidLatin1CombiningCharacterSelector = 3, + kCFStringEncodingPrecomposeLatin1CharacterSelector = 4 +}; + +extern const void *CFStringEncodingGetAddressForSelector(uint32_t selector); + +#define BOOTSTRAPFUNC_NAME CFStringEncodingBootstrap +typedef const CFStringEncodingConverter* (*CFStringEncodingBootstrapProc)(uint32_t encoding, const void *getSelector); + +/* Latin precomposition */ +/* This function does not precompose recursively nor to U+01E0 and U+01E1. +*/ +extern bool CFStringEncodingIsValidCombiningCharacterForLatin1(UniChar character); +extern UniChar CFStringEncodingPrecomposeLatinCharacter(const UniChar *character, CFIndex numChars, CFIndex *usedChars); + +/* Convenience functions for converter development */ +typedef struct _CFStringEncodingUnicodeTo8BitCharMap { + UniChar _u; + uint8_t _c; + uint8_t :8; +} CFStringEncodingUnicodeTo8BitCharMap; + +/* Binary searches CFStringEncodingUnicodeTo8BitCharMap */ +CF_INLINE bool CFStringEncodingUnicodeTo8BitEncoding(const CFStringEncodingUnicodeTo8BitCharMap *theTable, CFIndex numElem, UniChar character, uint8_t *ch) { + const CFStringEncodingUnicodeTo8BitCharMap *p, *q, *divider; + + if ((character < theTable[0]._u) || (character > theTable[numElem-1]._u)) { + return 0; + } + p = theTable; + q = p + (numElem-1); + while (p <= q) { + divider = p + ((q - p) >> 1); /* divide by 2 */ + if (character < divider->_u) { q = divider - 1; } + else if (character > divider->_u) { p = divider + 1; } + else { *ch = divider->_c; return 1; } + } + return 0; +} + + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERETEREXT__ */ + diff --git a/include/CoreFoundation/CFStringEncodingConverterPriv.h b/include/CoreFoundation/CFStringEncodingConverterPriv.h new file mode 100644 index 0000000..30b97df --- /dev/null +++ b/include/CoreFoundation/CFStringEncodingConverterPriv.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFStringEncodingConverterPriv.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__) +#define __COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__ 1 + +#include +#include "CFStringEncodingConverterExt.h" + +extern const CFStringEncodingConverter __CFConverterASCII; +extern const CFStringEncodingConverter __CFConverterISOLatin1; +extern const CFStringEncodingConverter __CFConverterMacRoman; +extern const CFStringEncodingConverter __CFConverterWinLatin1; +extern const CFStringEncodingConverter __CFConverterNextStepLatin; +extern const CFStringEncodingConverter __CFConverterUTF8; + +extern CFStringEncoding *__CFStringEncodingCreateListOfAvailablePlatformConverters(CFAllocatorRef allocator, CFIndex *numberOfConverters); +extern const CFStringEncodingConverter *__CFStringEncodingGetExternalConverter(uint32_t encoding); +extern CFIndex __CFStringEncodingPlatformUnicodeToBytes(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars, CFIndex *usedCharLen, uint8_t *bytes, CFIndex maxByteLen, CFIndex *usedByteLen); +extern CFIndex __CFStringEncodingPlatformBytesToUnicode(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes, CFIndex *usedByteLen, UniChar *characters, CFIndex maxCharLen, CFIndex *usedCharLen); +extern CFIndex __CFStringEncodingPlatformCharLengthForBytes(uint32_t encoding, uint32_t flags, const uint8_t *bytes, CFIndex numBytes); +extern CFIndex __CFStringEncodingPlatformByteLengthForCharacters(uint32_t encoding, uint32_t flags, const UniChar *characters, CFIndex numChars); + +#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGCONVERTERPRIV__ */ + diff --git a/include/CoreFoundation/CFStringEncodingDatabase.h b/include/CoreFoundation/CFStringEncodingDatabase.h new file mode 100644 index 0000000..4d4e491 --- /dev/null +++ b/include/CoreFoundation/CFStringEncodingDatabase.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + * CFStringEncodingDatabase.h + * CoreFoundation + * + * Created by Aki Inoue on 07/12/05. + * Copyright (c) 2007-2014, Apple Inc. All rights reserved. + * + */ + +#include + +CF_PRIVATE uint16_t __CFStringEncodingGetWindowsCodePage(CFStringEncoding encoding); +CF_PRIVATE CFStringEncoding __CFStringEncodingGetFromWindowsCodePage(uint16_t codepage); + +CF_PRIVATE bool __CFStringEncodingGetCanonicalName(CFStringEncoding encoding, char *buffer, CFIndex bufferSize); +CF_PRIVATE CFStringEncoding __CFStringEncodingGetFromCanonicalName(const char *canonicalName); + +CF_PRIVATE CFStringEncoding __CFStringEncodingGetMostCompatibleMacScript(CFStringEncoding encoding); + +CF_PRIVATE const char *__CFStringEncodingGetName(CFStringEncoding encoding); // Returns simple non-localizd name diff --git a/include/CoreFoundation/CFStringEncodingExt.h b/include/CoreFoundation/CFStringEncodingExt.h new file mode 100644 index 0000000..d11dead --- /dev/null +++ b/include/CoreFoundation/CFStringEncodingExt.h @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFStringEncodingExt.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFSTRINGENCODINGEXT__) +#define __COREFOUNDATION_CFSTRINGENCODINGEXT__ 1 + +#include + +CF_EXTERN_C_BEGIN + +typedef CF_ENUM(CFIndex, CFStringEncodings) { +/* kCFStringEncodingMacRoman = 0L, defined in CoreFoundation/CFString.h */ + kCFStringEncodingMacJapanese = 1, + kCFStringEncodingMacChineseTrad = 2, + kCFStringEncodingMacKorean = 3, + kCFStringEncodingMacArabic = 4, + kCFStringEncodingMacHebrew = 5, + kCFStringEncodingMacGreek = 6, + kCFStringEncodingMacCyrillic = 7, + kCFStringEncodingMacDevanagari = 9, + kCFStringEncodingMacGurmukhi = 10, + kCFStringEncodingMacGujarati = 11, + kCFStringEncodingMacOriya = 12, + kCFStringEncodingMacBengali = 13, + kCFStringEncodingMacTamil = 14, + kCFStringEncodingMacTelugu = 15, + kCFStringEncodingMacKannada = 16, + kCFStringEncodingMacMalayalam = 17, + kCFStringEncodingMacSinhalese = 18, + kCFStringEncodingMacBurmese = 19, + kCFStringEncodingMacKhmer = 20, + kCFStringEncodingMacThai = 21, + kCFStringEncodingMacLaotian = 22, + kCFStringEncodingMacGeorgian = 23, + kCFStringEncodingMacArmenian = 24, + kCFStringEncodingMacChineseSimp = 25, + kCFStringEncodingMacTibetan = 26, + kCFStringEncodingMacMongolian = 27, + kCFStringEncodingMacEthiopic = 28, + kCFStringEncodingMacCentralEurRoman = 29, + kCFStringEncodingMacVietnamese = 30, + kCFStringEncodingMacExtArabic = 31, + /* The following use script code 0, smRoman */ + kCFStringEncodingMacSymbol = 33, + kCFStringEncodingMacDingbats = 34, + kCFStringEncodingMacTurkish = 35, + kCFStringEncodingMacCroatian = 36, + kCFStringEncodingMacIcelandic = 37, + kCFStringEncodingMacRomanian = 38, + kCFStringEncodingMacCeltic = 39, + kCFStringEncodingMacGaelic = 40, + /* The following use script code 4, smArabic */ + kCFStringEncodingMacFarsi = 0x8C, /* Like MacArabic but uses Farsi digits */ + /* The following use script code 7, smCyrillic */ + kCFStringEncodingMacUkrainian = 0x98, + /* The following use script code 32, smUnimplemented */ + kCFStringEncodingMacInuit = 0xEC, + kCFStringEncodingMacVT100 = 0xFC, /* VT100/102 font from Comm Toolbox: Latin-1 repertoire + box drawing etc */ + /* Special Mac OS encodings*/ + kCFStringEncodingMacHFS = 0xFF, /* Meta-value, should never appear in a table */ + + /* Unicode & ISO UCS encodings begin at 0x100 */ + /* We don't use Unicode variations defined in TextEncoding; use the ones in CFString.h, instead. */ + + /* ISO 8-bit and 7-bit encodings begin at 0x200 */ +/* kCFStringEncodingISOLatin1 = 0x0201, defined in CoreFoundation/CFString.h */ + kCFStringEncodingISOLatin2 = 0x0202, /* ISO 8859-2 */ + kCFStringEncodingISOLatin3 = 0x0203, /* ISO 8859-3 */ + kCFStringEncodingISOLatin4 = 0x0204, /* ISO 8859-4 */ + kCFStringEncodingISOLatinCyrillic = 0x0205, /* ISO 8859-5 */ + kCFStringEncodingISOLatinArabic = 0x0206, /* ISO 8859-6, =ASMO 708, =DOS CP 708 */ + kCFStringEncodingISOLatinGreek = 0x0207, /* ISO 8859-7 */ + kCFStringEncodingISOLatinHebrew = 0x0208, /* ISO 8859-8 */ + kCFStringEncodingISOLatin5 = 0x0209, /* ISO 8859-9 */ + kCFStringEncodingISOLatin6 = 0x020A, /* ISO 8859-10 */ + kCFStringEncodingISOLatinThai = 0x020B, /* ISO 8859-11 */ + kCFStringEncodingISOLatin7 = 0x020D, /* ISO 8859-13 */ + kCFStringEncodingISOLatin8 = 0x020E, /* ISO 8859-14 */ + kCFStringEncodingISOLatin9 = 0x020F, /* ISO 8859-15 */ + kCFStringEncodingISOLatin10 = 0x0210, /* ISO 8859-16 */ + + /* MS-DOS & Windows encodings begin at 0x400 */ + kCFStringEncodingDOSLatinUS = 0x0400, /* code page 437 */ + kCFStringEncodingDOSGreek = 0x0405, /* code page 737 (formerly code page 437G) */ + kCFStringEncodingDOSBalticRim = 0x0406, /* code page 775 */ + kCFStringEncodingDOSLatin1 = 0x0410, /* code page 850, "Multilingual" */ + kCFStringEncodingDOSGreek1 = 0x0411, /* code page 851 */ + kCFStringEncodingDOSLatin2 = 0x0412, /* code page 852, Slavic */ + kCFStringEncodingDOSCyrillic = 0x0413, /* code page 855, IBM Cyrillic */ + kCFStringEncodingDOSTurkish = 0x0414, /* code page 857, IBM Turkish */ + kCFStringEncodingDOSPortuguese = 0x0415, /* code page 860 */ + kCFStringEncodingDOSIcelandic = 0x0416, /* code page 861 */ + kCFStringEncodingDOSHebrew = 0x0417, /* code page 862 */ + kCFStringEncodingDOSCanadianFrench = 0x0418, /* code page 863 */ + kCFStringEncodingDOSArabic = 0x0419, /* code page 864 */ + kCFStringEncodingDOSNordic = 0x041A, /* code page 865 */ + kCFStringEncodingDOSRussian = 0x041B, /* code page 866 */ + kCFStringEncodingDOSGreek2 = 0x041C, /* code page 869, IBM Modern Greek */ + kCFStringEncodingDOSThai = 0x041D, /* code page 874, also for Windows */ + kCFStringEncodingDOSJapanese = 0x0420, /* code page 932, also for Windows */ + kCFStringEncodingDOSChineseSimplif = 0x0421, /* code page 936, also for Windows */ + kCFStringEncodingDOSKorean = 0x0422, /* code page 949, also for Windows; Unified Hangul Code */ + kCFStringEncodingDOSChineseTrad = 0x0423, /* code page 950, also for Windows */ +/* kCFStringEncodingWindowsLatin1 = 0x0500, defined in CoreFoundation/CFString.h */ + kCFStringEncodingWindowsLatin2 = 0x0501, /* code page 1250, Central Europe */ + kCFStringEncodingWindowsCyrillic = 0x0502, /* code page 1251, Slavic Cyrillic */ + kCFStringEncodingWindowsGreek = 0x0503, /* code page 1253 */ + kCFStringEncodingWindowsLatin5 = 0x0504, /* code page 1254, Turkish */ + kCFStringEncodingWindowsHebrew = 0x0505, /* code page 1255 */ + kCFStringEncodingWindowsArabic = 0x0506, /* code page 1256 */ + kCFStringEncodingWindowsBalticRim = 0x0507, /* code page 1257 */ + kCFStringEncodingWindowsVietnamese = 0x0508, /* code page 1258 */ + kCFStringEncodingWindowsKoreanJohab = 0x0510, /* code page 1361, for Windows NT */ + + /* Various national standards begin at 0x600 */ +/* kCFStringEncodingASCII = 0x0600, defined in CoreFoundation/CFString.h */ + kCFStringEncodingANSEL = 0x0601, /* ANSEL (ANSI Z39.47) */ + kCFStringEncodingJIS_X0201_76 = 0x0620, + kCFStringEncodingJIS_X0208_83 = 0x0621, + kCFStringEncodingJIS_X0208_90 = 0x0622, + kCFStringEncodingJIS_X0212_90 = 0x0623, + kCFStringEncodingJIS_C6226_78 = 0x0624, + kCFStringEncodingShiftJIS_X0213 CF_ENUM_AVAILABLE(10_5, 2_0) = 0x0628, /* Shift-JIS format encoding of JIS X0213 planes 1 and 2*/ + kCFStringEncodingShiftJIS_X0213_MenKuTen = 0x0629, /* JIS X0213 in plane-row-column notation */ + kCFStringEncodingGB_2312_80 = 0x0630, + kCFStringEncodingGBK_95 = 0x0631, /* annex to GB 13000-93; for Windows 95 */ + kCFStringEncodingGB_18030_2000 = 0x0632, + kCFStringEncodingKSC_5601_87 = 0x0640, /* same as KSC 5601-92 without Johab annex */ + kCFStringEncodingKSC_5601_92_Johab = 0x0641, /* KSC 5601-92 Johab annex */ + kCFStringEncodingCNS_11643_92_P1 = 0x0651, /* CNS 11643-1992 plane 1 */ + kCFStringEncodingCNS_11643_92_P2 = 0x0652, /* CNS 11643-1992 plane 2 */ + kCFStringEncodingCNS_11643_92_P3 = 0x0653, /* CNS 11643-1992 plane 3 (was plane 14 in 1986 version) */ + + /* ISO 2022 collections begin at 0x800 */ + kCFStringEncodingISO_2022_JP = 0x0820, + kCFStringEncodingISO_2022_JP_2 = 0x0821, + kCFStringEncodingISO_2022_JP_1 = 0x0822, /* RFC 2237*/ + kCFStringEncodingISO_2022_JP_3 = 0x0823, /* JIS X0213*/ + kCFStringEncodingISO_2022_CN = 0x0830, + kCFStringEncodingISO_2022_CN_EXT = 0x0831, + kCFStringEncodingISO_2022_KR = 0x0840, + + /* EUC collections begin at 0x900 */ + kCFStringEncodingEUC_JP = 0x0920, /* ISO 646, 1-byte katakana, JIS 208, JIS 212 */ + kCFStringEncodingEUC_CN = 0x0930, /* ISO 646, GB 2312-80 */ + kCFStringEncodingEUC_TW = 0x0931, /* ISO 646, CNS 11643-1992 Planes 1-16 */ + kCFStringEncodingEUC_KR = 0x0940, /* ISO 646, KS C 5601-1987 */ + + /* Misc standards begin at 0xA00 */ + kCFStringEncodingShiftJIS = 0x0A01, /* plain Shift-JIS */ + kCFStringEncodingKOI8_R = 0x0A02, /* Russian internet standard */ + kCFStringEncodingBig5 = 0x0A03, /* Big-5 (has variants) */ + kCFStringEncodingMacRomanLatin1 = 0x0A04, /* Mac OS Roman permuted to align with ISO Latin-1 */ + kCFStringEncodingHZ_GB_2312 = 0x0A05, /* HZ (RFC 1842, for Chinese mail & news) */ + kCFStringEncodingBig5_HKSCS_1999 = 0x0A06, /* Big-5 with Hong Kong special char set supplement*/ + kCFStringEncodingVISCII = 0x0A07, /* RFC 1456, Vietnamese */ + kCFStringEncodingKOI8_U = 0x0A08, /* RFC 2319, Ukrainian */ + kCFStringEncodingBig5_E = 0x0A09, /* Taiwan Big-5E standard */ + + /* Other platform encodings*/ +/* kCFStringEncodingNextStepLatin = 0x0B01, defined in CoreFoundation/CFString.h */ + kCFStringEncodingNextStepJapanese = 0x0B02, /* NextStep Japanese encoding */ + + /* EBCDIC & IBM host encodings begin at 0xC00 */ + kCFStringEncodingEBCDIC_US = 0x0C01, /* basic EBCDIC-US */ + kCFStringEncodingEBCDIC_CP037 = 0x0C02, /* code page 037, extended EBCDIC (Latin-1 set) for US,Canada... */ + + kCFStringEncodingUTF7 CF_ENUM_AVAILABLE(10_6, 4_0) = 0x04000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF7Format RFC2152 */ + kCFStringEncodingUTF7_IMAP CF_ENUM_AVAILABLE(10_6, 4_0) = 0x0A10, /* UTF-7 (IMAP folder variant) RFC3501 */ + + /* Deprecated constants */ + kCFStringEncodingShiftJIS_X0213_00 = 0x0628 /* Shift-JIS format encoding of JIS X0213 planes 1 and 2 (DEPRECATED) */ +}; + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFSTRINGENCODINGEXT__ */ + diff --git a/include/CoreFoundation/CFStringTokenizer.h b/include/CoreFoundation/CFStringTokenizer.h new file mode 100644 index 0000000..7627ec6 --- /dev/null +++ b/include/CoreFoundation/CFStringTokenizer.h @@ -0,0 +1,46 @@ +#if !defined(__COREFOUNDATION_CFSTRINGTOKENIZER__) +#define __COREFOUNDATION_CFSTRINGTOKENIZER__ 1 + +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct __CFStringTokenizer *CFStringTokenizerRef; + +enum { + kCFStringTokenizerUnitWord = 0, + kCFStringTokenizerUnitSentence = 1, + kCFStringTokenizerUnitParagraph = 2, + kCFStringTokenizerUnitLineBreak = 3, + kCFStringTokenizerUnitWordBoundary = 4, + kCFStringTokenizerAttributeLatinTranscription = 1UL << 16, + kCFStringTokenizerAttributeLanguage = 1UL << 17, +}; + +typedef CF_OPTIONS(CFOptionFlags, CFStringTokenizerTokenType) { + kCFStringTokenizerTokenNone = 0, + kCFStringTokenizerTokenNormal = 1UL << 0, + kCFStringTokenizerTokenHasSubTokensMask = 1UL << 1, + kCFStringTokenizerTokenHasDerivedSubTokensMask = 1UL << 2, + kCFStringTokenizerTokenHasHasNumbersMask = 1UL << 3, + kCFStringTokenizerTokenHasNonLettersMask = 1UL << 4, + kCFStringTokenizerTokenIsCJWordMask = 1UL << 5 +}; + +CF_EXPORT CFStringRef CFStringTokenizerCopyBestStringLanguage(CFStringRef string, CFRange range); +CF_EXPORT CFTypeID CFStringTokenizerGetTypeID(void); +CF_EXPORT CFStringTokenizerRef CFStringTokenizerCreate(CFAllocatorRef alloc, CFStringRef string, CFRange range, CFOptionFlags options, CFLocaleRef locale); +CF_EXPORT void CFStringTokenizerSetString(CFStringTokenizerRef tokenizer, CFStringRef string, CFRange range); +CF_EXPORT CFStringTokenizerTokenType CFStringTokenizerGoToTokenAtIndex(CFStringTokenizerRef tokenizer, CFIndex index); +CF_EXPORT CFStringTokenizerTokenType CFStringTokenizerAdvanceToNextToken(CFStringTokenizerRef tokenizer); +CF_EXPORT CFRange CFStringTokenizerGetCurrentTokenRange(CFStringTokenizerRef tokenizer); +CF_EXPORT CFTypeRef CFStringTokenizerCopyCurrentTokenAttribute(CFStringTokenizerRef tokenizer, CFOptionFlags attribute); +CF_EXPORT CFIndex CFStringTokenizerGetCurrentSubTokens(CFStringTokenizerRef tokenizer, CFRange *ranges, CFIndex maxRangeLength, CFMutableArrayRef derivedSubTokens); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFSTRINGTOKENIZER__ */ diff --git a/include/CoreFoundation/CFTimeZone.h b/include/CoreFoundation/CFTimeZone.h new file mode 100644 index 0000000..47b3dc2 --- /dev/null +++ b/include/CoreFoundation/CFTimeZone.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFTimeZone.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFTIMEZONE__) +#define __COREFOUNDATION_CFTIMEZONE__ 1 + +#include +#include +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +CF_EXPORT +CFTypeID CFTimeZoneGetTypeID(void); + +CF_EXPORT +CFTimeZoneRef CFTimeZoneCopySystem(void); + +CF_EXPORT +void CFTimeZoneResetSystem(void); + +CF_EXPORT +CFTimeZoneRef CFTimeZoneCopyDefault(void); + +CF_EXPORT +void CFTimeZoneSetDefault(CFTimeZoneRef tz); + +CF_EXPORT +CFArrayRef CFTimeZoneCopyKnownNames(void); + +CF_EXPORT +CFDictionaryRef CFTimeZoneCopyAbbreviationDictionary(void); + +CF_EXPORT +void CFTimeZoneSetAbbreviationDictionary(CFDictionaryRef dict); + +CF_EXPORT +CFTimeZoneRef CFTimeZoneCreate(CFAllocatorRef allocator, CFStringRef name, CFDataRef data); + +CF_EXPORT +CFTimeZoneRef CFTimeZoneCreateWithTimeIntervalFromGMT(CFAllocatorRef allocator, CFTimeInterval ti); + +CF_EXPORT +CFTimeZoneRef CFTimeZoneCreateWithName(CFAllocatorRef allocator, CFStringRef name, Boolean tryAbbrev); + +CF_EXPORT +CFStringRef CFTimeZoneGetName(CFTimeZoneRef tz); + +CF_EXPORT +CFDataRef CFTimeZoneGetData(CFTimeZoneRef tz); + +CF_EXPORT +CFTimeInterval CFTimeZoneGetSecondsFromGMT(CFTimeZoneRef tz, CFAbsoluteTime at); + +CF_EXPORT +CFStringRef CFTimeZoneCopyAbbreviation(CFTimeZoneRef tz, CFAbsoluteTime at); + +CF_EXPORT +Boolean CFTimeZoneIsDaylightSavingTime(CFTimeZoneRef tz, CFAbsoluteTime at); + +CF_EXPORT +CFTimeInterval CFTimeZoneGetDaylightSavingTimeOffset(CFTimeZoneRef tz, CFAbsoluteTime at) CF_AVAILABLE(10_5, 2_0); + +CF_EXPORT +CFAbsoluteTime CFTimeZoneGetNextDaylightSavingTimeTransition(CFTimeZoneRef tz, CFAbsoluteTime at) CF_AVAILABLE(10_5, 2_0); + +typedef CF_ENUM(CFIndex, CFTimeZoneNameStyle) { + kCFTimeZoneNameStyleStandard, + kCFTimeZoneNameStyleShortStandard, + kCFTimeZoneNameStyleDaylightSaving, + kCFTimeZoneNameStyleShortDaylightSaving, + kCFTimeZoneNameStyleGeneric, + kCFTimeZoneNameStyleShortGeneric +} CF_ENUM_AVAILABLE(10_5, 2_0); + +CF_EXPORT +CFStringRef CFTimeZoneCopyLocalizedName(CFTimeZoneRef tz, CFTimeZoneNameStyle style, CFLocaleRef locale) CF_AVAILABLE(10_5, 2_0); + +CF_EXPORT +const CFStringRef kCFTimeZoneSystemTimeZoneDidChangeNotification CF_AVAILABLE(10_5, 2_0); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFTIMEZONE__ */ + diff --git a/include/CoreFoundation/CFTree.h b/include/CoreFoundation/CFTree.h new file mode 100644 index 0000000..278cbc2 --- /dev/null +++ b/include/CoreFoundation/CFTree.h @@ -0,0 +1,349 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFTree.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ +/*! + @header CFTree + CFTree implements a container which stores references to other CFTrees. + Each tree may have a parent, and a variable number of children. +*/ + +#if !defined(__COREFOUNDATION_CFTREE__) +#define __COREFOUNDATION_CFTREE__ 1 + +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +/*! + @typedef CFTreeRetainCallBack + Type of the callback function used to add a retain to the user-specified + info parameter. This callback may returns the value to use whenever the + info parameter is retained, which is usually the value parameter passed + to this callback, but may be a different value if a different value + should be used. + @param info A user-supplied info parameter provided in a CFTreeContext. + @result The retained info parameter. +*/ +typedef const void * (*CFTreeRetainCallBack)(const void *info); + +/*! + @typedef CFTreeReleaseCallBack + Type of the callback function used to remove a retain previously + added to the user-specified info parameter. + @param info A user-supplied info parameter provided in a CFTreeContext. +*/ +typedef void (*CFTreeReleaseCallBack)(const void *info); + +/*! + @typedef CFTreeCopyDescriptionCallBack + Type of the callback function used to provide a description of the + user-specified info parameter. + @param info A user-supplied info parameter provided in a CFTreeContext. + @result A description of the info parameter. +*/ +typedef CFStringRef (*CFTreeCopyDescriptionCallBack)(const void *info); + +/*! + @typedef CFTreeContext + Structure containing user-specified data and callbacks for a CFTree. + @field version The version number of the structure type being passed + in as a parameter to the CFTree creation function. + This structure is version 0. + @field info A C pointer to a user-specified block of data. + @field retain The callback used to add a retain for the info field. + If this parameter is not a pointer to a function of the correct + prototype, the behavior is undefined. The value may be NULL. + @field release The calllback used to remove a retain previously added + for the info field. If this parameter is not a pointer to a + function of the correct prototype, the behavior is undefined. + The value may be NULL. + @field copyDescription The callback used to provide a description of + the info field. +*/ +typedef struct { + CFIndex version; + void * info; + CFTreeRetainCallBack retain; + CFTreeReleaseCallBack release; + CFTreeCopyDescriptionCallBack copyDescription; +} CFTreeContext; + +/*! + @typedef CFTreeApplierFunction + Type of the callback function used by the apply functions of + CFTree. + @param value The current value from the CFTree + @param context The user-defined context parameter give to the apply + function. +*/ +typedef void (*CFTreeApplierFunction)(const void *value, void *context); + +/*! + @typedef CFTreeRef + This is the type of a reference to CFTrees. +*/ +typedef struct __CFTree * CFTreeRef; + +/*! + @function CFTreeGetTypeID + Returns the type identifier of all CFTree instances. +*/ +CF_EXPORT +CFTypeID CFTreeGetTypeID(void); + +/*! + @function CFTreeCreate + Creates a new mutable tree. + @param allocator The CFAllocator which should be used to allocate + memory for the tree and storage for its children. This + parameter may be NULL in which case the current default + CFAllocator is used. If this reference is not a valid + CFAllocator, the behavior is undefined. + @param context A C pointer to a CFTreeContext structure to be copied + and used as the context of the new tree. The info parameter + will be retained by the tree if a retain function is provided. + If this value is not a valid C pointer to a CFTreeContext + structure-sized block of storage, the result is undefined. + If the version number of the storage is not a valid CFTreeContext + version number, the result is undefined. + @result A reference to the new CFTree. +*/ +CF_EXPORT +CFTreeRef CFTreeCreate(CFAllocatorRef allocator, const CFTreeContext *context); + +/*! + @function CFTreeGetParent + Returns the parent of the specified tree. + @param tree The tree to be queried. If this parameter is not a valid + CFTree, the behavior is undefined. + @result The parent of the tree. +*/ +CF_EXPORT +CFTreeRef CFTreeGetParent(CFTreeRef tree); + +/*! + @function CFTreeGetNextSibling + Returns the sibling after the specified tree in the parent tree's list. + @param tree The tree to be queried. If this parameter is not a valid + CFTree, the behavior is undefined. + @result The next sibling of the tree. +*/ +CF_EXPORT +CFTreeRef CFTreeGetNextSibling(CFTreeRef tree); + +/*! + @function CFTreeGetFirstChild + Returns the first child of the tree. + @param tree The tree to be queried. If this parameter is not a valid + CFTree, the behavior is undefined. + @result The first child of the tree. +*/ +CF_EXPORT +CFTreeRef CFTreeGetFirstChild(CFTreeRef tree); + +/*! + @function CFTreeGetContext + Returns the context of the specified tree. + @param tree The tree to be queried. If this parameter is not a valid + CFTree, the behavior is undefined. + @param context A C pointer to a CFTreeContext structure to be filled in with + the context of the specified tree. If this value is not a valid C + pointer to a CFTreeContext structure-sized block of storage, the + result is undefined. If the version number of the storage is not + a valid CFTreeContext version number, the result is undefined. +*/ +CF_EXPORT +void CFTreeGetContext(CFTreeRef tree, CFTreeContext *context); + +/*! + @function CFTreeGetChildCount + Returns the number of children of the specified tree. + @param tree The tree to be queried. If this parameter is not a valid + CFTree, the behavior is undefined. + @result The number of children. +*/ +CF_EXPORT +CFIndex CFTreeGetChildCount(CFTreeRef tree); + +/*! + @function CFTreeGetChildAtIndex + Returns the nth child of the specified tree. + @param tree The tree to be queried. If this parameter is not a valid + CFTree, the behavior is undefined. + @param idx The index of the child tree to be returned. If this parameter + is less than zero or greater than the number of children of the + tree, the result is undefined. + @result A reference to the specified child tree. +*/ +CF_EXPORT +CFTreeRef CFTreeGetChildAtIndex(CFTreeRef tree, CFIndex idx); + +/*! + @function CFTreeGetChildren + Fills the buffer with children from the tree. + @param tree The tree to be queried. If this parameter is not a valid + CFTree, the behavior is undefined. + @param children A C array of pointer-sized values to be filled with + children from the tree. If this parameter is not a valid pointer to a + C array of at least CFTreeGetChildCount() pointers, the behavior is undefined. + @result A reference to the specified child tree. +*/ +CF_EXPORT +void CFTreeGetChildren(CFTreeRef tree, CFTreeRef *children); + +/*! + @function CFTreeApplyFunctionToChildren + Calls a function once for each child of the tree. Note that the applier + only operates one level deep, and does not operate on descendents further + removed than the immediate children of the tree. + @param heap The tree to be operated upon. If this parameter is not a + valid CFTree, the behavior is undefined. + @param applier The callback function to call once for each child of + the given tree. If this parameter is not a pointer to a + function of the correct prototype, the behavior is undefined. + If there are values in the tree which the applier function does + not expect or cannot properly apply to, the behavior is undefined. + @param context A pointer-sized user-defined value, which is passed + as the second parameter to the applier function, but is + otherwise unused by this function. If the context is not + what is expected by the applier function, the behavior is + undefined. +*/ +CF_EXPORT +void CFTreeApplyFunctionToChildren(CFTreeRef tree, CFTreeApplierFunction applier, void *context); + +/*! + @function CFTreeFindRoot + Returns the root tree of which the specified tree is a descendent. + @param tree The tree to be queried. If this parameter is not a valid + CFTree, the behavior is undefined. + @result A reference to the root of the tree. +*/ +CF_EXPORT +CFTreeRef CFTreeFindRoot(CFTreeRef tree); + +/*! + @function CFTreeSetContext + Replaces the context of a tree. The tree releases its retain on the + info of the previous context, and retains the info of the new context. + @param tree The tree to be operated on. If this parameter is not a valid + CFTree, the behavior is undefined. + @param context A C pointer to a CFTreeContext structure to be copied + and used as the context of the new tree. The info parameter + will be retained by the tree if a retain function is provided. + If this value is not a valid C pointer to a CFTreeContext + structure-sized block of storage, the result is undefined. + If the version number of the storage is not a valid CFTreeContext + version number, the result is undefined. +*/ +CF_EXPORT +void CFTreeSetContext(CFTreeRef tree, const CFTreeContext *context); + +/*! + @function CFTreePrependChild + Adds the newChild to the specified tree as the first in its list of children. + @param tree The tree to be operated on. If this parameter is not a valid + CFTree, the behavior is undefined. + @param newChild The child to be added. + If this parameter is not a valid CFTree, the behavior is undefined. + If this parameter is a tree which is already a child of any tree, + the behavior is undefined. +*/ +CF_EXPORT +void CFTreePrependChild(CFTreeRef tree, CFTreeRef newChild); + +/*! + @function CFTreeAppendChild + Adds the newChild to the specified tree as the last in its list of children. + @param tree The tree to be operated on. If this parameter is not a valid + CFTree, the behavior is undefined. + @param newChild The child to be added. + If this parameter is not a valid CFTree, the behavior is undefined. + If this parameter is a tree which is already a child of any tree, + the behavior is undefined. +*/ +CF_EXPORT +void CFTreeAppendChild(CFTreeRef tree, CFTreeRef newChild); + +/*! + @function CFTreeInsertSibling + Inserts newSibling into the the parent tree's linked list of children after + tree. The newSibling will have the same parent as tree. + @param tree The tree to insert newSibling after. If this parameter is not a valid + CFTree, the behavior is undefined. If the tree does not have a + parent, the behavior is undefined. + @param newSibling The sibling to be added. + If this parameter is not a valid CFTree, the behavior is undefined. + If this parameter is a tree which is already a child of any tree, + the behavior is undefined. +*/ +CF_EXPORT +void CFTreeInsertSibling(CFTreeRef tree, CFTreeRef newSibling); + +/*! + @function CFTreeRemove + Removes the tree from its parent. + @param tree The tree to be removed. If this parameter is not a valid + CFTree, the behavior is undefined. +*/ +CF_EXPORT +void CFTreeRemove(CFTreeRef tree); + +/*! + @function CFTreeRemoveAllChildren + Removes all the children of the tree. + @param tree The tree to remove all children from. If this parameter is not a valid + CFTree, the behavior is undefined. +*/ +CF_EXPORT +void CFTreeRemoveAllChildren(CFTreeRef tree); + +/*! + @function CFTreeSortChildren + Sorts the children of the specified tree using the specified comparator function. + @param tree The tree to be operated on. If this parameter is not a valid + CFTree, the behavior is undefined. + @param comparator The function with the comparator function type + signature which is used in the sort operation to compare + children of the tree with the given value. If this parameter + is not a pointer to a function of the correct prototype, the + the behavior is undefined. The children of the tree are sorted + from least to greatest according to this function. + @param context A pointer-sized user-defined value, which is passed + as the third parameter to the comparator function, but is + otherwise unused by this function. If the context is not + what is expected by the comparator function, the behavior is + undefined. +*/ +CF_EXPORT +void CFTreeSortChildren(CFTreeRef tree, CFComparatorFunction comparator, void *context); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFTREE__ */ + diff --git a/include/CoreFoundation/CFURL.h b/include/CoreFoundation/CFURL.h new file mode 100644 index 0000000..6b6d95f --- /dev/null +++ b/include/CoreFoundation/CFURL.h @@ -0,0 +1,1160 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFURL.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFURL__) +#define __COREFOUNDATION_CFURL__ 1 + +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef CF_ENUM(CFIndex, CFURLPathStyle) { + kCFURLPOSIXPathStyle = 0, + kCFURLHFSPathStyle CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0), /* The use of kCFURLHFSPathStyle is deprecated. The Carbon File Manager, which uses HFS style paths, is deprecated. HFS style paths are unreliable because they can arbitrarily refer to multiple volumes if those volumes have identical volume names. You should instead use kCFURLPOSIXPathStyle wherever possible. */ + kCFURLWindowsPathStyle +}; + +typedef const struct CF_BRIDGED_TYPE(NSURL) __CFURL * CFURLRef; + +/* CFURLs are composed of two fundamental pieces - their string, and a */ +/* (possibly NULL) base URL. A relative URL is one in which the string */ +/* by itself does not fully specify the URL (for instance "myDir/image.tiff"); */ +/* an absolute URL is one in which the string does fully specify the URL */ +/* ("file://localhost/myDir/image.tiff"). Absolute URLs always have NULL */ +/* base URLs; however, it is possible for a URL to have a NULL base, and still */ +/* not be absolute. Such a URL has only a relative string, and cannot be */ +/* resolved. Two CFURLs are considered equal if and only if their strings */ +/* are equal and their bases are equal. In other words, */ +/* "file://localhost/myDir/image.tiff" is NOT equal to the URL with relative */ +/* string "myDir/image.tiff" and base URL "file://localhost/". Clients that */ +/* need these less strict form of equality should convert all URLs to their */ +/* absolute form via CFURLCopyAbsoluteURL(), then compare the absolute forms. */ + +CF_EXPORT +CFTypeID CFURLGetTypeID(void); + +/* encoding will be used both to interpret the bytes of URLBytes, and to */ +/* interpret any percent-escapes within the bytes. */ +/* Using a string encoding which isn't a superset of ASCII encoding is not */ +/* supported because CFURLGetBytes and CFURLGetByteRangeForComponent require */ +/* 7-bit ASCII characters to be stored in a single 8-bit byte. */ +/* CFStringEncodings which are a superset of ASCII encoding include MacRoman, */ +/* WindowsLatin1, ISOLatin1, NextStepLatin, ASCII, and UTF8. */ +CF_EXPORT +CFURLRef CFURLCreateWithBytes(CFAllocatorRef allocator, const UInt8 *URLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL); + +/* Escapes any character that is not 7-bit ASCII with the byte-code */ +/* for the given encoding. If escapeWhitespace is true, whitespace */ +/* characters (' ', '\t', '\r', '\n') will be escaped also (desirable */ +/* if embedding the URL into a larger text stream like HTML) */ +CF_EXPORT +CFDataRef CFURLCreateData(CFAllocatorRef allocator, CFURLRef url, CFStringEncoding encoding, Boolean escapeWhitespace); + +/* Any escape sequences in URLString will be interpreted via UTF-8. */ +CF_EXPORT +CFURLRef CFURLCreateWithString(CFAllocatorRef allocator, CFStringRef URLString, CFURLRef baseURL); + +/* Create an absolute URL directly, without requiring the extra step */ +/* of calling CFURLCopyAbsoluteURL(). If useCompatibilityMode is */ +/* true, the rules historically used on the web are used to resolve */ +/* relativeString against baseURL - these rules are generally listed */ +/* in the RFC as optional or alternate interpretations. Otherwise, */ +/* the strict rules from the RFC are used. The major differences are */ +/* that in compatibility mode, we are lenient of the scheme appearing */ +/* in relative portion, leading "../" components are removed from the */ +/* final URL's path, and if the relative portion contains only */ +/* resource specifier pieces (query, parameters, and fragment), then */ +/* the last path component of the base URL will not be deleted. */ +/* Using a string encoding which isn't a superset of ASCII encoding is not */ +/* supported because CFURLGetBytes and CFURLGetByteRangeForComponent require */ +/* 7-bit ASCII characters to be stored in a single 8-bit byte. */ +/* CFStringEncodings which are a superset of ASCII encoding include MacRoman, */ +/* WindowsLatin1, ISOLatin1, NextStepLatin, ASCII, and UTF8. */ +CF_EXPORT +CFURLRef CFURLCreateAbsoluteURLWithBytes(CFAllocatorRef alloc, const UInt8 *relativeURLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL, Boolean useCompatibilityMode); + +/* filePath should be the URL's path expressed as a path of the type */ +/* fsType. If filePath is not absolute, the resulting URL will be */ +/* considered relative to the current working directory (evaluated */ +/* at creation time). isDirectory determines whether filePath is */ +/* treated as a directory path when resolving against relative path */ +/* components */ +CF_EXPORT +CFURLRef CFURLCreateWithFileSystemPath(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory); + +CF_EXPORT +CFURLRef CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory); + +/* The path style of the baseURL must match the path style of the relative */ +/* url or the results are undefined. If the provided filePath looks like an */ +/* absolute path ( starting with '/' if pathStyle is kCFURLPosixPathStyle, */ +/* not starting with ':' for kCFURLHFSPathStyle, or starting with what looks */ +/* like a drive letter and colon for kCFURLWindowsPathStyle ) then the baseURL */ +/* is ignored. */ +CF_EXPORT +CFURLRef CFURLCreateWithFileSystemPathRelativeToBase(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL); + +CF_EXPORT +CFURLRef CFURLCreateFromFileSystemRepresentationRelativeToBase(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory, CFURLRef baseURL); + +/* Fills buffer with the file system's native representation of */ +/* url's path. No more than maxBufLen bytes are written to buffer. */ +/* The buffer should be at least the maximum path length for */ +/* the file system in question to avoid failures for insufficiently */ +/* large buffers. If resolveAgainstBase is true, the url's relative */ +/* portion is resolved against its base before the path is computed. */ +/* Returns success or failure. */ +CF_EXPORT +Boolean CFURLGetFileSystemRepresentation(CFURLRef url, Boolean resolveAgainstBase, UInt8 *buffer, CFIndex maxBufLen); + +/* Creates a new URL by resolving the relative portion of relativeURL against its base. */ +CF_EXPORT +CFURLRef CFURLCopyAbsoluteURL(CFURLRef relativeURL); + +/* Returns the URL's string. */ +CF_EXPORT +CFStringRef CFURLGetString(CFURLRef anURL); + +/* Returns the base URL if it exists */ +CF_EXPORT +CFURLRef CFURLGetBaseURL(CFURLRef anURL); + +/* +All URLs can be broken into two pieces - the scheme (preceding the +first colon) and the resource specifier (following the first colon). +Most URLs are also "standard" URLs conforming to RFC 1808 (available +from www.w3c.org). This category includes URLs of the file, http, +https, and ftp schemes, to name a few. Standard URLs start the +resource specifier with two slashes ("//"), and can be broken into +four distinct pieces - the scheme, the net location, the path, and +further resource specifiers (typically an optional parameter, query, +and/or fragment). The net location appears immediately following +the two slashes and goes up to the next slash; it's format is +scheme-specific, but is usually composed of some or all of a username, +password, host name, and port. The path is a series of path components +separated by slashes; if the net location is present, the path always +begins with a slash. Standard URLs can be relative to another URL, +in which case at least the scheme and possibly other pieces as well +come from the base URL (see RFC 1808 for precise details when resolving +a relative URL against its base). The full URL is therefore + + "://" + +If a given CFURL can be decomposed (that is, conforms to RFC 1808), you +can ask for each of the four basic pieces (scheme, net location, path, +and resource specifer) separately, as well as for its base URL. The +basic pieces are returned with any percent escape sequences still in +place (although note that the scheme may not legally include any +percent escapes); this is to allow the caller to distinguish between +percent sequences that may have syntactic meaning if replaced by the +character being escaped (for instance, a '/' in a path component). +Since only the individual schemes know which characters are +syntactically significant, CFURL cannot safely replace any percent +escape sequences. However, you can use +CFURLCreateStringByReplacingPercentEscapes() to create a new string with +the percent escapes removed; see below. + +If a given CFURL can not be decomposed, you can ask for its scheme and its +resource specifier; asking it for its net location or path will return NULL. + +To get more refined information about the components of a decomposable +CFURL, you may ask for more specific pieces of the URL, expressed with +the percent escapes removed. The available functions are CFURLCopyHostName(), +CFURLGetPortNumber() (returns an Int32), CFURLCopyUserName(), +CFURLCopyPassword(), CFURLCopyQuery(), CFURLCopyParameters(), and +CFURLCopyFragment(). Because the parameters, query, and fragment of an +URL may contain scheme-specific syntaxes, these methods take a second +argument, giving a list of characters which should NOT be replaced if +percent escaped. For instance, the ftp parameter syntax gives simple +key-value pairs as "=;" Clearly if a key or value includes +either '=' or ';', it must be escaped to avoid corrupting the meaning of +the parameters, so the caller may request the parameter string as + +CFStringRef myParams = CFURLCopyParameters(ftpURL, CFSTR("=;%")); + +requesting that all percent escape sequences be replaced by the represented +characters, except for escaped '=', '%' or ';' characters. Pass the empty +string (CFSTR("")) to request that all percent escapes be replaced, or NULL +to request that none be. +*/ + +/* Returns true if anURL conforms to RFC 1808 */ +CF_EXPORT +Boolean CFURLCanBeDecomposed(CFURLRef anURL); + +/* The next several methods leave any percent escape sequences intact */ + +CF_EXPORT +CFStringRef CFURLCopyScheme(CFURLRef anURL); + +/* NULL if CFURLCanBeDecomposed(anURL) is false */ +CF_EXPORT +CFStringRef CFURLCopyNetLocation(CFURLRef anURL); + +/* NULL if CFURLCanBeDecomposed(anURL) is false; also does not resolve the URL */ +/* against its base. See also CFURLCopyAbsoluteURL(). Note that, strictly */ +/* speaking, any leading '/' is not considered part of the URL's path, although */ +/* its presence or absence determines whether the path is absolute. */ +/* CFURLCopyPath()'s return value includes any leading slash (giving the path */ +/* the normal POSIX appearance); CFURLCopyStrictPath()'s return value omits any */ +/* leading slash, and uses isAbsolute to report whether the URL's path is absolute. */ + +/* CFURLCopyFileSystemPath() returns the URL's path as a file system path for the */ +/* given path style. All percent escape sequences are replaced. The URL is not */ +/* resolved against its base before computing the path. */ +CF_EXPORT +CFStringRef CFURLCopyPath(CFURLRef anURL); + +CF_EXPORT +CFStringRef CFURLCopyStrictPath(CFURLRef anURL, Boolean *isAbsolute); + +CF_EXPORT +CFStringRef CFURLCopyFileSystemPath(CFURLRef anURL, CFURLPathStyle pathStyle); + +/* Returns whether anURL's path represents a directory */ +/* (true returned) or a simple file (false returned) */ +CF_EXPORT +Boolean CFURLHasDirectoryPath(CFURLRef anURL); + +/* Any additional resource specifiers after the path. For URLs */ +/* that cannot be decomposed, this is everything except the scheme itself. */ +CF_EXPORT +CFStringRef CFURLCopyResourceSpecifier(CFURLRef anURL); + +CF_EXPORT +CFStringRef CFURLCopyHostName(CFURLRef anURL); + +CF_EXPORT +SInt32 CFURLGetPortNumber(CFURLRef anURL); /* Returns -1 if no port number is specified */ + +CF_EXPORT +CFStringRef CFURLCopyUserName(CFURLRef anURL); + +CF_EXPORT +CFStringRef CFURLCopyPassword(CFURLRef anURL); + +/* These remove all percent escape sequences except those for */ +/* characters in charactersToLeaveEscaped. If charactersToLeaveEscaped */ +/* is empty (""), all percent escape sequences are replaced by their */ +/* corresponding characters. If charactersToLeaveEscaped is NULL, */ +/* then no escape sequences are removed at all */ +CF_EXPORT +CFStringRef CFURLCopyParameterString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped); + +CF_EXPORT +CFStringRef CFURLCopyQueryString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped); + +CF_EXPORT +CFStringRef CFURLCopyFragment(CFURLRef anURL, CFStringRef charactersToLeaveEscaped); + +CF_EXPORT +CFStringRef CFURLCopyLastPathComponent(CFURLRef url); + +CF_EXPORT +CFStringRef CFURLCopyPathExtension(CFURLRef url); + +/* These functions all treat the base URL of the supplied url as */ +/* invariant. In other words, the URL returned will always have */ +/* the same base as the URL supplied as an argument. */ + +CF_EXPORT +CFURLRef CFURLCreateCopyAppendingPathComponent(CFAllocatorRef allocator, CFURLRef url, CFStringRef pathComponent, Boolean isDirectory); + +CF_EXPORT +CFURLRef CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator, CFURLRef url); + +CF_EXPORT +CFURLRef CFURLCreateCopyAppendingPathExtension(CFAllocatorRef allocator, CFURLRef url, CFStringRef extension); + +CF_EXPORT +CFURLRef CFURLCreateCopyDeletingPathExtension(CFAllocatorRef allocator, CFURLRef url); + +/* Fills buffer with the bytes for url, returning the number of bytes */ +/* filled. If buffer is of insufficient size, returns -1 and no bytes */ +/* are placed in buffer. If buffer is NULL, the needed length is */ +/* computed and returned. The returned bytes are the original bytes */ +/* from which the URL was created; if the URL was created from a */ +/* string, the bytes will be the bytes of the string encoded via UTF-8 */ +CF_EXPORT +CFIndex CFURLGetBytes(CFURLRef url, UInt8 *buffer, CFIndex bufferLength); + +typedef CF_ENUM(CFIndex, CFURLComponentType) { + kCFURLComponentScheme = 1, + kCFURLComponentNetLocation = 2, + kCFURLComponentPath = 3, + kCFURLComponentResourceSpecifier = 4, + + kCFURLComponentUser = 5, + kCFURLComponentPassword = 6, + kCFURLComponentUserInfo = 7, + kCFURLComponentHost = 8, + kCFURLComponentPort = 9, + kCFURLComponentParameterString = 10, + kCFURLComponentQuery = 11, + kCFURLComponentFragment = 12 +}; + +/* +Gets the range of the requested component in the bytes of url, as +returned by CFURLGetBytes(). This range is only good for use in the +bytes returned by CFURLGetBytes! + +If non-NULL, rangeIncludingSeparators gives the range of component +including the sequences that separate component from the previous and +next components. If there is no previous or next component, that end of +rangeIncludingSeparators will match the range of the component itself. +If url does not contain the given component type, (kCFNotFound, 0) is +returned, and rangeIncludingSeparators is set to the location where the +component would be inserted. Some examples - + +For the URL http://www.apple.com/hotnews/ + +Component returned range rangeIncludingSeparators +scheme (0, 4) (0, 7) +net location (7, 13) (4, 16) +path (20, 9) (20, 9) +resource specifier (kCFNotFound, 0) (29, 0) +user (kCFNotFound, 0) (7, 0) +password (kCFNotFound, 0) (7, 0) +user info (kCFNotFound, 0) (7, 0) +host (7, 13) (4, 16) +port (kCFNotFound, 0) (20, 0) +parameter (kCFNotFound, 0) (29, 0) +query (kCFNotFound, 0) (29, 0) +fragment (kCFNotFound, 0) (29, 0) + + +For the URL ./relPath/file.html#fragment + +Component returned range rangeIncludingSeparators +scheme (kCFNotFound, 0) (0, 0) +net location (kCFNotFound, 0) (0, 0) +path (0, 19) (0, 20) +resource specifier (20, 8) (19, 9) +user (kCFNotFound, 0) (0, 0) +password (kCFNotFound, 0) (0, 0) +user info (kCFNotFound, 0) (0, 0) +host (kCFNotFound, 0) (0, 0) +port (kCFNotFound, 0) (0, 0) +parameter (kCFNotFound, 0) (19, 0) +query (kCFNotFound, 0) (19, 0) +fragment (20, 8) (19, 9) + + +For the URL scheme://user:pass@host:1/path/path2/file.html;params?query#fragment + +Component returned range rangeIncludingSeparators +scheme (0, 6) (0, 9) +net location (9, 16) (6, 19) +path (25, 21) (25, 22) +resource specifier (47, 21) (46, 22) +user (9, 4) (6, 8) +password (14, 4) (13, 6) +user info (9, 9) (6, 13) +host (19, 4) (18, 6) +port (24, 1) (23, 2) +parameter (47, 6) (46, 8) +query (54, 5) (53, 7) +fragment (60, 8) (59, 9) +*/ +CF_EXPORT +CFRange CFURLGetByteRangeForComponent(CFURLRef url, CFURLComponentType component, CFRange *rangeIncludingSeparators); + +/* Returns a string with any percent escape sequences that do NOT */ +/* correspond to characters in charactersToLeaveEscaped with their */ +/* equivalent. Returns NULL on failure (if an invalid percent sequence */ +/* is encountered), or the original string (retained) if no characters */ +/* need to be replaced. Pass NULL to request that no percent escapes be */ +/* replaced, or the empty string (CFSTR("")) to request that all percent */ +/* escapes be replaced. Uses UTF8 to interpret percent escapes. */ +CF_EXPORT +CFStringRef CFURLCreateStringByReplacingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveEscaped); + +/* As above, but allows you to specify the encoding to use when interpreting percent escapes */ +CF_EXPORT +CFStringRef CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFAllocatorRef allocator, CFStringRef origString, CFStringRef charsToLeaveEscaped, CFStringEncoding encoding); + +/* Creates a copy or originalString, replacing certain characters with */ +/* the equivalent percent escape sequence based on the encoding specified. */ +/* If the originalString does not need to be modified (no percent escape */ +/* sequences are missing), may retain and return originalString. */ +/* If you are uncertain of the correct encoding, you should use UTF-8, */ +/* which is the encoding designated by RFC 2396 as the correct encoding */ +/* for use in URLs. The characters so escaped are all characters that */ +/* are not legal URL characters (based on RFC 2396), plus any characters */ +/* in legalURLCharactersToBeEscaped, less any characters in */ +/* charactersToLeaveUnescaped. To simply correct any non-URL characters */ +/* in an otherwise correct URL string, do: */ + +/* newString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, origString, NULL, NULL, kCFStringEncodingUTF8); */ +CF_EXPORT +CFStringRef CFURLCreateStringByAddingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding); + + +#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION +CF_IMPLICIT_BRIDGING_DISABLED + +/* + CFURLIsFileReferenceURL + + Returns whether the URL is a file reference URL. + + Parameters + url + The URL specifying the resource. + */ +CF_EXPORT +Boolean CFURLIsFileReferenceURL(CFURLRef url) CF_AVAILABLE(10_9, 7_0); + +/* + CFURLCreateFileReferenceURL + + Returns a new file reference URL that refers to the same resource as a specified URL. + + Parameters + allocator + The memory allocator for creating the new URL. + url + The file URL specifying the resource. + error + On output when the result is NULL, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. + + Return Value + The new file reference URL, or NULL if an error occurs. + + Discussion + File reference URLs use a URL path syntax that identifies a file system object by reference, not by path. This form of file URL remains valid when the file system path of the URL’s underlying resource changes. An error will occur if the url parameter is not a file URL. File reference URLs cannot be created to file system objects which do not exist or are not reachable. In some areas of the file system hierarchy, file reference URLs cannot be generated to the leaf node of the URL path. A file reference URL's path should never be persistently stored because is not valid across system restarts, and across remounts of volumes -- if you want to create a persistent reference to a file system object, use a bookmark (see CFURLCreateBookmarkData). If this function returns NULL, the optional error is populated. This function is currently applicable only to URLs for file system resources. + Symbol is present in iOS 4, but performs no operation. + */ +CF_EXPORT +CFURLRef CFURLCreateFileReferenceURL(CFAllocatorRef allocator, CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + + +/* + CFURLCreateFilePathURL + + Returns a new file path URL that refers to the same resource as a specified URL. + + Parameters + allocator + The memory allocator for creating the new URL. + url + The file URL specifying the resource. + error + On output when the result is NULL, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. + + Return Value + The new file path URL, or NULL if an error occurs. + + Discussion + File path URLs use a file system style path. An error will occur if the url parameter is not a file URL. A file reference URL's resource must exist and be reachable to be converted to a file path URL. If this function returns NULL, the optional error is populated. This function is currently applicable only to URLs for file system resources. + Symbol is present in iOS 4, but performs no operation. + */ +CF_EXPORT +CFURLRef CFURLCreateFilePathURL(CFAllocatorRef allocator, CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + +CF_IMPLICIT_BRIDGING_ENABLED +#endif + + + +#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION +CF_IMPLICIT_BRIDGING_DISABLED + +/* Resource access + + The behavior of resource value caching is slightly different between the NSURL and CFURL API. + + When the NSURL methods which get, set, or use cached resource values are used from the main thread, resource values cached by the URL (except those added as temporary properties) are invalidated the next time the main thread's run loop runs. + + The CFURL functions do not automatically clear any resource values cached by the URL. The client has complete control over the cache lifetime. If you are using CFURL API, you must use CFURLClearResourcePropertyCacheForKey or CFURLClearResourcePropertyCache to clear cached resource values. + */ + + +/* + CFURLCopyResourcePropertyForKey + + Returns the resource value identified by a given resource key. + + Parameters + url + The URL specifying the resource. + key + The resource key that identifies the resource property. + propertyValueTypeRefPtr + On output when the result is true, the resource value or NULL. + error + On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. + + Return Value + true if propertyValueTypeRefPtr is successfully populated; false if an error occurs. + + Discussion + CFURLCopyResourcePropertyForKey first checks if the URL object already caches the resource value. If so, it returns the cached resource value to the caller. If not, then CFURLCopyResourcePropertyForKey synchronously obtains the resource value from the backing store, adds the resource value to the URL object's cache, and returns the resource value to the caller. The type of the resource value varies by resource property (see resource key definitions). If this function returns true and propertyValueTypeRefPtr is populated with NULL, it means the resource property is not available for the specified resource and no errors occurred when determining the resource property was not available. If this function returns false, the optional error is populated. This function is currently applicable only to URLs for file system resources. + Symbol is present in iOS 4, but performs no operation. + */ +CF_EXPORT +Boolean CFURLCopyResourcePropertyForKey(CFURLRef url, CFStringRef key, void *propertyValueTypeRefPtr, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + + +/* + CFURLCopyResourcePropertiesForKeys + + Returns the resource values identified by specified array of resource keys. + + Parameters + url + The URL specifying the resource. + keys + An array of resource keys that identify the resource properties. + error + On output when the result is NULL, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. + + Return Value + A dictionary of resource values indexed by resource key; NULL if an error occurs. + + Discussion + CFURLCopyResourcePropertiesForKeys first checks if the URL object already caches the resource values. If so, it returns the cached resource values to the caller. If not, then CFURLCopyResourcePropertyForKey synchronously obtains the resource values from the backing store, adds the resource values to the URL object's cache, and returns the resource values to the caller. The type of the resource values vary by property (see resource key definitions). If the result dictionary does not contain a resource value for one or more of the requested resource keys, it means those resource properties are not available for the specified resource and no errors occurred when determining those resource properties were not available. If this function returns NULL, the optional error is populated. This function is currently applicable only to URLs for file system resources. + Symbol is present in iOS 4, but performs no operation. + */ +CF_EXPORT +CFDictionaryRef CFURLCopyResourcePropertiesForKeys(CFURLRef url, CFArrayRef keys, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + + +/* + CFURLSetResourcePropertyForKey + + Sets the resource value identified by a given resource key. + + Parameters + url + The URL specifying the resource. + key + The resource key that identifies the resource property. + propertyValue + The resource value. + error + On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. + + Return Value + true if the attempt to set the resource value completed with no errors; otherwise, false. + + Discussion + CFURLSetResourcePropertyForKey writes the new resource value out to the backing store. Attempts to set a read-only resource property or to set a resource property not supported by the resource are ignored and are not considered errors. If this function returns false, the optional error is populated. This function is currently applicable only to URLs for file system resources. + Symbol is present in iOS 4, but performs no operation. + */ +CF_EXPORT +Boolean CFURLSetResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + + +/* + CFURLSetResourcePropertiesForKeys + + Sets any number of resource values of a URL's resource. + + Parameters + url + The URL specifying the resource. + keyedPropertyValues + A dictionary of resource values indexed by resource keys. + error + On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. + + Return Value + true if the attempt to set the resource values completed with no errors; otherwise, false. + + Discussion + CFURLSetResourcePropertiesForKeys writes the new resource values out to the backing store. Attempts to set read-only resource properties or to set resource properties not supported by the resource are ignored and are not considered errors. If an error occurs after some resource properties have been successfully changed, the userInfo dictionary in the returned error contains an array of resource keys that were not set with the key kCFURLKeysOfUnsetValuesKey. The order in which the resource values are set is not defined. If you need to guarantee the order resource values are set, you should make multiple requests to CFURLSetResourcePropertiesForKeys or CFURLSetResourcePropertyForKey to guarantee the order. If this function returns false, the optional error is populated. This function is currently applicable only to URLs for file system resources. + Symbol is present in iOS 4, but performs no operation. + */ +CF_EXPORT +Boolean CFURLSetResourcePropertiesForKeys(CFURLRef url, CFDictionaryRef keyedPropertyValues, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + + +CF_EXPORT +const CFStringRef kCFURLKeysOfUnsetValuesKey CF_AVAILABLE(10_7, 5_0); + /* Key for the resource properties that have not been set after the CFURLSetResourcePropertiesForKeys function returns an error, returned as an array of of CFString objects. */ + + +/* + CFURLClearResourcePropertyCacheForKey + + Discards a cached resource value of a URL. + + Parameters + url + The URL specifying the resource. + key + The resource key that identifies the resource property. + + Discussion + Discarding a cached resource value may discard other cached resource values, because some resource values are cached as a set of values and because some resource values depend on other resource values (temporary properties have no dependencies). This function is currently applicable only to URLs for file system resources. + Symbol is present in iOS 4, but performs no operation. + */ +CF_EXPORT +void CFURLClearResourcePropertyCacheForKey(CFURLRef url, CFStringRef key) CF_AVAILABLE(10_6, 4_0); + + +/* + CFURLClearResourcePropertyCache + + Discards all cached resource values of a URL. + + Parameters + url + The URL specifying the resource. + + Discussion + All temporary properties are also cleared from the URL object's cache. This function is currently applicable only to URLs for file system resources. + Symbol is present in iOS 4, but performs no operation. + */ +CF_EXPORT +void CFURLClearResourcePropertyCache(CFURLRef url) CF_AVAILABLE(10_6, 4_0); + + +/* + CFURLSetTemporaryResourcePropertyForKey + + Sets a temporary resource value on the URL object. + + Parameters + url + The URL object. + key + The resource key that identifies the temporary resource property. + propertyValue + The resource value. + + Discussion + Temporary properties are for client use. Temporary properties exist only in memory and are never written to the resource's backing store. Once set, a temporary value can be copied from the URL object with CFURLCopyResourcePropertyForKey and CFURLCopyResourcePropertiesForKeys. To remove a temporary value from the URL object, use CFURLClearResourcePropertyCacheForKey. Temporary values must be valid Core Foundation types, and will be retained by CFURLSetTemporaryResourcePropertyForKey. Care should be taken to ensure the key that identifies a temporary resource property is unique and does not conflict with system defined keys (using reverse domain name notation in your temporary resource property keys is recommended). This function is currently applicable only to URLs for file system resources. + Symbol is present in iOS 4, but performs no operation. + */ +CF_EXPORT +void CFURLSetTemporaryResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue) CF_AVAILABLE(10_6, 4_0); + + +/* + CFURLResourceIsReachable + + Returns whether the URL's resource exists and is reachable. + + Parameters + url + The URL object. + error + On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error. + + Return Value + true if the resource is reachable; otherwise, false. + + Discussion + CFURLResourceIsReachable synchronously checks if the resource's backing store is reachable. Checking reachability is appropriate when making decisions that do not require other immediate operations on the resource, e.g. periodic maintenance of UI state that depends on the existence of a specific document. When performing operations such as opening a file or copying resource properties, it is more efficient to simply try the operation and handle failures. This function is currently applicable only to URLs for file system resources. If this function returns false, the optional error is populated. For other URL types, false is returned. + Symbol is present in iOS 4, but performs no operation. + */ +CF_EXPORT +Boolean CFURLResourceIsReachable(CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + +CF_IMPLICIT_BRIDGING_ENABLED + + +/* Properties of File System Resources */ + +CF_EXPORT +const CFStringRef kCFURLNameKey CF_AVAILABLE(10_6, 4_0); + /* The resource name provided by the file system (Read-write, value type CFString) */ + +CF_EXPORT +const CFStringRef kCFURLLocalizedNameKey CF_AVAILABLE(10_6, 4_0); + /* Localized or extension-hidden name as displayed to users (Read-only, value type CFString) */ + +CF_EXPORT +const CFStringRef kCFURLIsRegularFileKey CF_AVAILABLE(10_6, 4_0); + /* True for regular files (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLIsDirectoryKey CF_AVAILABLE(10_6, 4_0); + /* True for directories (Read-only, CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLIsSymbolicLinkKey CF_AVAILABLE(10_6, 4_0); + /* True for symlinks (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLIsVolumeKey CF_AVAILABLE(10_6, 4_0); + /* True for the root directory of a volume (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLIsPackageKey CF_AVAILABLE(10_6, 4_0); + /* True for packaged directories (Read-only 10_6 and 10_7, read-write 10_8, value type CFBoolean). Note: You can only set or clear this property on directories; if you try to set this property on non-directory objects, the property is ignored. If the directory is a package for some other reason (extension type, etc), setting this property to false will have no effect. */ + +CF_EXPORT +const CFStringRef kCFURLIsSystemImmutableKey CF_AVAILABLE(10_6, 4_0); + /* True for system-immutable resources (Read-write, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLIsUserImmutableKey CF_AVAILABLE(10_6, 4_0); + /* True for user-immutable resources (Read-write, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLIsHiddenKey CF_AVAILABLE(10_6, 4_0); + /* True for resources normally not displayed to users (Read-write, value type CFBoolean). Note: If the resource is a hidden because its name starts with a period, setting this property to false will not change the property. */ + +CF_EXPORT +const CFStringRef kCFURLHasHiddenExtensionKey CF_AVAILABLE(10_6, 4_0); + /* True for resources whose filename extension is removed from the localized name property (Read-write, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLCreationDateKey CF_AVAILABLE(10_6, 4_0); + /* The date the resource was created (Read-write, value type CFDate) */ + +CF_EXPORT +const CFStringRef kCFURLContentAccessDateKey CF_AVAILABLE(10_6, 4_0); + /* The date the resource was last accessed (Read-only, value type CFDate) */ + +CF_EXPORT +const CFStringRef kCFURLContentModificationDateKey CF_AVAILABLE(10_6, 4_0); + /* The time the resource content was last modified (Read-write, value type CFDate) */ + +CF_EXPORT +const CFStringRef kCFURLAttributeModificationDateKey CF_AVAILABLE(10_6, 4_0); + /* The time the resource's attributes were last modified (Read-write, value type CFDate) */ + +CF_EXPORT +const CFStringRef kCFURLLinkCountKey CF_AVAILABLE(10_6, 4_0); + /* Number of hard links to the resource (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLParentDirectoryURLKey CF_AVAILABLE(10_6, 4_0); + /* The resource's parent directory, if any (Read-only, value type CFURL) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeURLKey CF_AVAILABLE(10_6, 4_0); + /* URL of the volume on which the resource is stored (Read-only, value type CFURL) */ + +CF_EXPORT +const CFStringRef kCFURLTypeIdentifierKey CF_AVAILABLE(10_6, 4_0); + /* Uniform type identifier (UTI) for the resource (Read-only, value type CFString) */ + +CF_EXPORT +const CFStringRef kCFURLLocalizedTypeDescriptionKey CF_AVAILABLE(10_6, 4_0); + /* User-visible type or "kind" description (Read-only, value type CFString) */ + +CF_EXPORT +const CFStringRef kCFURLLabelNumberKey CF_AVAILABLE(10_6, 4_0); + /* The label number assigned to the resource (Read-write, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLLabelColorKey CF_AVAILABLE(10_6, 4_0); + /* The color of the assigned label (Currently not implemented, value type CGColorRef, must link with Application Services) */ + +CF_EXPORT +const CFStringRef kCFURLLocalizedLabelKey CF_AVAILABLE(10_6, 4_0); + /* The user-visible label text (Read-only, value type CFString) */ + +CF_EXPORT +const CFStringRef kCFURLEffectiveIconKey CF_AVAILABLE(10_6, 4_0); + /* The icon normally displayed for the resource (Read-only, value type CGImageRef, must link with Application Services) */ + +CF_EXPORT +const CFStringRef kCFURLCustomIconKey CF_AVAILABLE(10_6, 4_0); + /* The custom icon assigned to the resource, if any (Currently not implemented, value type CGImageRef, must link with Application Services) */ + +CF_EXPORT +const CFStringRef kCFURLFileResourceIdentifierKey CF_AVAILABLE(10_7, 5_0); + /* An identifier which can be used to compare two file system objects for equality using CFEqual (i.e, two object identifiers are equal if they have the same file system path or if the paths are linked to same inode on the same file system). This identifier is not persistent across system restarts. (Read-only, value type CFType) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeIdentifierKey CF_AVAILABLE(10_7, 5_0); + /* An identifier that can be used to identify the volume the file system object is on. Other objects on the same volume will have the same volume identifier and can be compared using for equality using CFEqual. This identifier is not persistent across system restarts. (Read-only, value type CFType) */ + +CF_EXPORT +const CFStringRef kCFURLPreferredIOBlockSizeKey CF_AVAILABLE(10_7, 5_0); + /* The optimal block size when reading or writing this file's data, or NULL if not available. (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLIsReadableKey CF_AVAILABLE(10_7, 5_0); + /* true if this process (as determined by EUID) can read the resource. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLIsWritableKey CF_AVAILABLE(10_7, 5_0); + /* true if this process (as determined by EUID) can write to the resource. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLIsExecutableKey CF_AVAILABLE(10_7, 5_0); + /* true if this process (as determined by EUID) can execute a file resource or search a directory resource. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLFileSecurityKey CF_AVAILABLE(10_7, 5_0); + /* The file system object's security information encapsulated in a CFFileSecurity object. (Read-write, value type CFFileSecurity) */ + +CF_EXPORT +const CFStringRef kCFURLIsExcludedFromBackupKey CF_AVAILABLE(10_8, 5_1); + /* true if resource should be excluded from backups, false otherwise (Read-write, value type CFBoolean). This property is only useful for excluding cache and other application support files which are not needed in a backup. Some operations commonly made to user documents will cause this property to be reset to false and so this property should not be used on user documents. */ + +CF_EXPORT +const CFStringRef kCFURLTagNamesKey CF_AVAILABLE(10_9, NA); + /* The array of Tag names (Read-write, value type CFArray of CFString) */ + +CF_EXPORT +const CFStringRef kCFURLPathKey CF_AVAILABLE(10_8, 6_0); + /* the URL's path as a file system path (Read-only, value type CFString) */ + +CF_EXPORT +const CFStringRef kCFURLIsMountTriggerKey CF_AVAILABLE(10_7, 4_0); + /* true if this URL is a file system trigger directory. Traversing or opening a file system trigger will cause an attempt to mount a file system on the trigger directory. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLGenerationIdentifierKey CF_AVAILABLE(10_10, 8_0); + /* An opaque generation identifier which can be compared using CFEqual() to determine if the data in a document has been modified. For URLs which refer to the same file inode, the generation identifier will change when the data in the file's data fork is changed (changes to extended attributes or other file system metadata do not change the generation identifier). For URLs which refer to the same directory inode, the generation identifier will change when direct children of that directory are added, removed or renamed (changes to the data of the direct children of that directory will not change the generation identifier). The generation identifier is persistent across system restarts. The generation identifier is tied to a specific document on a specific volume and is not transferred when the document is copied to another volume. This property is not supported by all volumes. (Read-only, value type CFType) */ + +CF_EXPORT +const CFStringRef kCFURLDocumentIdentifierKey CF_AVAILABLE(10_10, 8_0); + /* The document identifier -- a value assigned by the kernel to a document (which can be either a file or directory) and is used to identify the document regardless of where it gets moved on a volume. The document identifier survives "safe save” operations; i.e it is sticky to the path it was assigned to (-replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error: is the preferred safe-save API). The document identifier is persistent across system restarts. The document identifier is not transferred when the file is copied. Document identifiers are only unique within a single volume. This property is not supported by all volumes. (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLAddedToDirectoryDateKey CF_AVAILABLE(10_10, 8_0); + /* The date the resource was created, or renamed into or within its parent directory. Note that inconsistent behavior may be observed when this attribute is requested on hard-linked items. This property is not supported by all volumes. (Read-only, value type CFDate) */ + +CF_EXPORT +const CFStringRef kCFURLQuarantinePropertiesKey CF_AVAILABLE(10_10, NA); + /* The quarantine properties as defined in LSQuarantine.h. To remove quarantine information from a file, pass kCFNull as the value when setting this property. (Read-write, value type CFDictionary) */ + +CF_EXPORT +const CFStringRef kCFURLFileResourceTypeKey CF_AVAILABLE(10_7, 5_0); + /* Returns the file system object type. (Read-only, value type CFString) */ + +/* The file system object type values returned for the kCFURLFileResourceTypeKey */ +CF_EXPORT +const CFStringRef kCFURLFileResourceTypeNamedPipe CF_AVAILABLE(10_7, 5_0); +CF_EXPORT +const CFStringRef kCFURLFileResourceTypeCharacterSpecial CF_AVAILABLE(10_7, 5_0); +CF_EXPORT +const CFStringRef kCFURLFileResourceTypeDirectory CF_AVAILABLE(10_7, 5_0); +CF_EXPORT +const CFStringRef kCFURLFileResourceTypeBlockSpecial CF_AVAILABLE(10_7, 5_0); +CF_EXPORT +const CFStringRef kCFURLFileResourceTypeRegular CF_AVAILABLE(10_7, 5_0); +CF_EXPORT +const CFStringRef kCFURLFileResourceTypeSymbolicLink CF_AVAILABLE(10_7, 5_0); +CF_EXPORT +const CFStringRef kCFURLFileResourceTypeSocket CF_AVAILABLE(10_7, 5_0); +CF_EXPORT +const CFStringRef kCFURLFileResourceTypeUnknown CF_AVAILABLE(10_7, 5_0); + +/* File Properties */ + +CF_EXPORT +const CFStringRef kCFURLFileSizeKey CF_AVAILABLE(10_6, 4_0); + /* Total file size in bytes (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLFileAllocatedSizeKey CF_AVAILABLE(10_6, 4_0); + /* Total size allocated on disk for the file in bytes (number of blocks times block size) (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLTotalFileSizeKey CF_AVAILABLE(10_7, 5_0); + /* Total displayable size of the file in bytes (this may include space used by metadata), or NULL if not available. (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLTotalFileAllocatedSizeKey CF_AVAILABLE(10_7, 5_0); + /* Total allocated size of the file in bytes (this may include space used by metadata), or NULL if not available. This can be less than the value returned by kCFURLTotalFileSizeKey if the resource is compressed. (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLIsAliasFileKey CF_AVAILABLE(10_6, 4_0); + /* true if the resource is a Finder alias file or a symlink, false otherwise ( Read-only, value type CFBooleanRef) */ + + +/* Volume Properties */ + +/* As a convenience, volume properties can be requested from any file system URL. The value returned will reflect the property value for the volume on which the resource is located. */ + +CF_EXPORT +const CFStringRef kCFURLVolumeLocalizedFormatDescriptionKey CF_AVAILABLE(10_6, 4_0); + /* The user-visible volume format (Read-only, value type CFString) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeTotalCapacityKey CF_AVAILABLE(10_6, 4_0); + /* Total volume capacity in bytes (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeAvailableCapacityKey CF_AVAILABLE(10_6, 4_0); + /* Total free space in bytes (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeResourceCountKey CF_AVAILABLE(10_6, 4_0); + /* Total number of resources on the volume (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsPersistentIDsKey CF_AVAILABLE(10_6, 4_0); + /* true if the volume format supports persistent object identifiers and can look up file system objects by their IDs (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsSymbolicLinksKey CF_AVAILABLE(10_6, 4_0); + /* true if the volume format supports symbolic links (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsHardLinksKey CF_AVAILABLE(10_6, 4_0); + /* true if the volume format supports hard links (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsJournalingKey CF_AVAILABLE(10_6, 4_0); + /* true if the volume format supports a journal used to speed recovery in case of unplanned restart (such as a power outage or crash). This does not necessarily mean the volume is actively using a journal. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeIsJournalingKey CF_AVAILABLE(10_6, 4_0); + /* true if the volume is currently using a journal for speedy recovery after an unplanned restart. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsSparseFilesKey CF_AVAILABLE(10_6, 4_0); + /* true if the volume format supports sparse files, that is, files which can have 'holes' that have never been written to, and thus do not consume space on disk. A sparse file may have an allocated size on disk that is less than its logical length. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsZeroRunsKey CF_AVAILABLE(10_6, 4_0); + /* For security reasons, parts of a file (runs) that have never been written to must appear to contain zeroes. true if the volume keeps track of allocated but unwritten runs of a file so that it can substitute zeroes without actually writing zeroes to the media. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsCaseSensitiveNamesKey CF_AVAILABLE(10_6, 4_0); + /* true if the volume format treats upper and lower case characters in file and directory names as different. Otherwise an upper case character is equivalent to a lower case character, and you can't have two names that differ solely in the case of the characters. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsCasePreservedNamesKey CF_AVAILABLE(10_6, 4_0); + /* true if the volume format preserves the case of file and directory names. Otherwise the volume may change the case of some characters (typically making them all upper or all lower case). (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsRootDirectoryDatesKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume supports reliable storage of times for the root directory. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsVolumeSizesKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume supports returning volume size values (kCFURLVolumeTotalCapacityKey and kCFURLVolumeAvailableCapacityKey). (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsRenamingKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume can be renamed. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsAdvisoryFileLockingKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume implements whole-file flock(2) style advisory locks, and the O_EXLOCK and O_SHLOCK flags of the open(2) call. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeSupportsExtendedSecurityKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume implements extended security (ACLs). (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeIsBrowsableKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume should be visible via the GUI (i.e., appear on the Desktop as a separate volume). (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeMaximumFileSizeKey CF_AVAILABLE(10_7, 5_0); + /* The largest file size (in bytes) supported by this file system, or NULL if this cannot be determined. (Read-only, value type CFNumber) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeIsEjectableKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume's media is ejectable from the drive mechanism under software control. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeIsRemovableKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume's media is removable from the drive mechanism. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeIsInternalKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume's device is connected to an internal bus, false if connected to an external bus, or NULL if not available. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeIsAutomountedKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume is automounted. Note: do not mistake this with the functionality provided by kCFURLVolumeSupportsBrowsingKey. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeIsLocalKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume is stored on a local device. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeIsReadOnlyKey CF_AVAILABLE(10_7, 5_0); + /* true if the volume is read-only. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeCreationDateKey CF_AVAILABLE(10_7, 5_0); + /* The volume's creation date, or NULL if this cannot be determined. (Read-only, value type CFDate) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeURLForRemountingKey CF_AVAILABLE(10_7, 5_0); + /* The CFURL needed to remount a network volume, or NULL if not available. (Read-only, value type CFURL) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeUUIDStringKey CF_AVAILABLE(10_7, 5_0); + /* The volume's persistent UUID as a string, or NULL if a persistent UUID is not available for the volume. (Read-only, value type CFString) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeNameKey CF_AVAILABLE(10_7, 5_0); + /* The name of the volume (Read-write, settable if kCFURLVolumeSupportsRenamingKey is true and permissions allow, value type CFString) */ + +CF_EXPORT +const CFStringRef kCFURLVolumeLocalizedNameKey CF_AVAILABLE(10_7, 5_0); + /* The user-presentable name of the volume (Read-only, value type CFString) */ + +/* UbiquitousItem Properties */ + +CF_EXPORT +const CFStringRef kCFURLIsUbiquitousItemKey CF_AVAILABLE(10_7, 5_0); + /* true if this item is synced to the cloud, false if it is only a local file. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemHasUnresolvedConflictsKey CF_AVAILABLE(10_7, 5_0); + /* true if this item has conflicts outstanding. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemIsDownloadedKey CF_DEPRECATED(10_7, 10_9, 5_0, 7_0, "Use kCFURLUbiquitousItemDownloadingStatusKey instead"); + /* Equivalent to NSURLUbiquitousItemDownloadingStatusKey == NSURLUbiquitousItemDownloadingStatusCurrent. Has never behaved as documented in earlier releases, hence deprecated. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemIsDownloadingKey CF_AVAILABLE(10_7, 5_0); + /* true if data is being downloaded for this item. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemIsUploadedKey CF_AVAILABLE(10_7, 5_0); + /* true if there is data present in the cloud for this item. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemIsUploadingKey CF_AVAILABLE(10_7, 5_0); + /* true if data is being uploaded for this item. (Read-only, value type CFBoolean) */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemPercentDownloadedKey CF_DEPRECATED(10_7, 10_8, 5_0, 6_0, "Use NSMetadataQuery and NSMetadataUbiquitousItemPercentDownloadedKey on NSMetadataItem instead"); + /* Use NSMetadataQuery and NSMetadataUbiquitousItemPercentDownloadedKey on NSMetadataItem instead */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemPercentUploadedKey CF_DEPRECATED(10_7, 10_8, 5_0, 6_0, "Use NSMetadataQuery and NSMetadataUbiquitousItemPercentUploadedKey on NSMetadataItem instead"); + /* Use NSMetadataQuery and NSMetadataUbiquitousItemPercentUploadedKey on NSMetadataItem instead */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemDownloadingStatusKey CF_AVAILABLE(10_9, 7_0); + /* Returns the download status of this item. (Read-only, value type CFString). Possible values below. */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemDownloadingErrorKey CF_AVAILABLE(10_9, 7_0); + /* returns the error when downloading the item from iCloud failed. See the NSUbiquitousFile section in FoundationErrors.h. (Read-only, value type CFError) */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemUploadingErrorKey CF_AVAILABLE(10_9, 7_0); + /* returns the error when uploading the item to iCloud failed. See the NSUbiquitousFile section in FoundationErrors.h. (Read-only, value type CFError) */ + +/* The values returned for kCFURLUbiquitousItemDownloadingStatusKey + */ +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemDownloadingStatusNotDownloaded CF_AVAILABLE(10_9, 7_0); + /* this item has not been downloaded yet. Use NSFileManager's startDownloadingUbiquitousItemAtURL:error: to download it */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemDownloadingStatusDownloaded CF_AVAILABLE(10_9, 7_0); + /* there is a local version of this item available. The most current version will get downloaded as soon as possible. */ + +CF_EXPORT +const CFStringRef kCFURLUbiquitousItemDownloadingStatusCurrent CF_AVAILABLE(10_9, 7_0); + /* there is a local version of this item and it is the most up-to-date version known to this device. */ + + +typedef CF_OPTIONS(CFOptionFlags, CFURLBookmarkCreationOptions) { + kCFURLBookmarkCreationMinimalBookmarkMask = ( 1UL << 9 ), // creates bookmark data with "less" information, which may be smaller but still be able to resolve in certain ways + kCFURLBookmarkCreationSuitableForBookmarkFile = ( 1UL << 10 ), // include the properties required by CFURLWriteBookmarkDataToFile() in the bookmark data created + kCFURLBookmarkCreationWithSecurityScope CF_ENUM_AVAILABLE(10_7, NA) = ( 1UL << 11 ), // Mac OS X 10.7.3 and later, include information in the bookmark data which allows the same sandboxed process to access the resource after being relaunched + kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess CF_ENUM_AVAILABLE(10_7, NA) = ( 1UL << 12 ), // Mac OS X 10.7.3 and later, if used with kCFURLBookmarkCreationWithSecurityScope, at resolution time only read access to the resource will be granted + + // deprecated + kCFURLBookmarkCreationPreferFileIDResolutionMask CF_ENUM_DEPRECATED(10_6, 10_9, 4_0, 7_0, "kCFURLBookmarkCreationPreferFileIDResolutionMask does nothing and has no effect on bookmark resolution" ) = ( 1UL << 8 ), +} CF_ENUM_AVAILABLE(10_6, 4_0); + +typedef CF_OPTIONS(CFOptionFlags, CFURLBookmarkResolutionOptions) { + kCFURLBookmarkResolutionWithoutUIMask = ( 1UL << 8 ), // don't perform any user interaction during bookmark resolution + kCFURLBookmarkResolutionWithoutMountingMask = ( 1UL << 9 ), // don't mount a volume during bookmark resolution + kCFURLBookmarkResolutionWithSecurityScope CF_ENUM_AVAILABLE(10_7, NA) = ( 1UL << 10 ), // Mac OS X 10.7.3 and later, use the secure information included at creation time to provide the ability to access the resource in a sandboxed process. + + kCFBookmarkResolutionWithoutUIMask = kCFURLBookmarkResolutionWithoutUIMask, + kCFBookmarkResolutionWithoutMountingMask = kCFURLBookmarkResolutionWithoutMountingMask, +} CF_ENUM_AVAILABLE(10_6, 4_0); + +typedef CFOptionFlags CFURLBookmarkFileCreationOptions; + +CF_IMPLICIT_BRIDGING_DISABLED + +/* Returns bookmark data for the URL, created with specified options and resource properties. If this function returns NULL, the optional error is populated. + */ +CF_EXPORT +CFDataRef CFURLCreateBookmarkData ( CFAllocatorRef allocator, CFURLRef url, CFURLBookmarkCreationOptions options, CFArrayRef resourcePropertiesToInclude, CFURLRef relativeToURL, CFErrorRef* error ) CF_AVAILABLE(10_6, 4_0); + +/* Return a URL that refers to a location specified by resolving bookmark data. If this function returns NULL, the optional error is populated. + */ +CF_EXPORT +CFURLRef CFURLCreateByResolvingBookmarkData ( CFAllocatorRef allocator, CFDataRef bookmark, CFURLBookmarkResolutionOptions options, CFURLRef relativeToURL, CFArrayRef resourcePropertiesToInclude, Boolean* isStale, CFErrorRef* error ) CF_AVAILABLE(10_6, 4_0); + +/* Returns the resource propertyies identified by a specified array of keys contained in specified bookmark data. If the result dictionary does not contain a resource value for one or more of the requested resource keys, it means those resource properties are not available in the bookmark data. + */ +CF_EXPORT +CFDictionaryRef CFURLCreateResourcePropertiesForKeysFromBookmarkData ( CFAllocatorRef allocator, CFArrayRef resourcePropertiesToReturn, CFDataRef bookmark ) CF_AVAILABLE(10_6, 4_0); + +/* Returns the resource property identified by a given resource key contained in specified bookmark data. If this function returns NULL, it means the resource property is not available in the bookmark data. + */ +CF_EXPORT +CFTypeRef CFURLCreateResourcePropertyForKeyFromBookmarkData( CFAllocatorRef allocator, CFStringRef resourcePropertyKey, CFDataRef bookmark ) CF_AVAILABLE(10_6, 4_0); + +/* Returns bookmark data derived from an alias file referred to by fileURL. If fileURL refers to an alias file created prior to OS X v10.6 that contains Alias Manager information but no bookmark data, this method synthesizes bookmark data for the file. If this method returns NULL, the optional error is populated. + */ +CF_EXPORT +CFDataRef CFURLCreateBookmarkDataFromFile(CFAllocatorRef allocator, CFURLRef fileURL, CFErrorRef *errorRef ) CF_AVAILABLE(10_6, 5_0); + +/* Creates an alias file on disk at a specified location with specified bookmark data. The bookmark data must have been created with the kCFURLBookmarkCreationSuitableForBookmarkFile option. fileURL must either refer to an existing file (which will be overwritten), or to location in an existing directory. If this method returns FALSE, the optional error is populated. + */ +CF_EXPORT +Boolean CFURLWriteBookmarkDataToFile( CFDataRef bookmarkRef, CFURLRef fileURL, CFURLBookmarkFileCreationOptions options, CFErrorRef *errorRef ) CF_AVAILABLE(10_6, 5_0); + +/* Returns bookmark data derived from an alias record. + */ +CF_EXPORT +CFDataRef CFURLCreateBookmarkDataFromAliasRecord ( CFAllocatorRef allocatorRef, CFDataRef aliasRecordDataRef ) CF_AVAILABLE_MAC(10_6); + +CF_IMPLICIT_BRIDGING_ENABLED + +/* Given a CFURLRef created by resolving a bookmark data created with security scope, make the resource referenced by the url accessible to the process. When access to this resource is no longer needed the client must call CFURLStopAccessingSecurityScopedResource(). Each call to CFURLStartAccessingSecurityScopedResource() must be balanced with a call to CFURLStopAccessingSecurityScopedResource() (Note: this is not reference counted). + */ +CF_EXPORT +Boolean CFURLStartAccessingSecurityScopedResource(CFURLRef url) CF_AVAILABLE(10_7, 8_0); // On OSX, available in MacOS X 10.7.3 and later + +/* Revokes the access granted to the url by a prior successful call to CFURLStartAccessingSecurityScopedResource(). + */ +CF_EXPORT +void CFURLStopAccessingSecurityScopedResource(CFURLRef url) CF_AVAILABLE(10_7, 8_0); // On OSX, available in MacOS X 10.7.3 and later + +#endif /* TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE */ + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFURL__ */ + diff --git a/include/CoreFoundation/CFURL.inc.h b/include/CoreFoundation/CFURL.inc.h new file mode 100644 index 0000000..b373493 --- /dev/null +++ b/include/CoreFoundation/CFURL.inc.h @@ -0,0 +1,364 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFURL.inc.h + Copyright (c) 2012-2014, Apple Inc. All rights reserved. + Responsibility: Jim Luther/Chris Linn +*/ + + +/* + + What's this file for? + + CFURL's URL string parser needs to be able to parse either an array of char or an array of UniChar. + + The code in CFURL.c used to use this macro "#define STRING_CHAR(x) (useCString ? cstring[(x)] : ustring[(x)])" to determine which array to get a character from for every character looked at in the URL string. That macro added one or more compare and branch instructins to the parser's execution for *every* character in the URL string. Those extra compares and branches added up to 10% of the time (for long URL strings) it takes to create a URL object. + + To ensure the exact same parser code is run over a char or a UniChar string, the source code was move to this .h file and is included multiple times by CFURL.c as needed. "STRING_CHAR(x)" was replaced by "characterArray[x]", and characterArray is defined as either an "const char *" or a "const UniChar *" for the two sets of function headers that are either parsing an array of char or an array of UniChar. + + Any changes made to the parser are made in this file so that both char and the UniChar strings are parsed exactly the same way. + + */ + +/* + static void _parseComponentsCString(CFAllocatorRef alloc, CFURLRef baseURL, CFIndex cfStringLength, const char *characterArray, UInt32 *theFlags, CFRange *packedRanges, uint8_t *numberOfRanges) + or + static void _parseComponentsUString(CFAllocatorRef alloc, CFURLRef baseURL, CFIndex cfStringLength, const UniChar *characterArray, UInt32 *theFlags, CFRange *packedRanges, uint8_t *numberOfRanges) + */ +#ifdef CFURL_INCLUDE_PARSE_COMPONENTS // defined when we want this block of code included +{ + /* index gives the URL part involved; to calculate the correct range index, use the number of the bit of the equivalent flag (i.e. the host flag is HAS_HOST, which is 0x8. so the range index for the host is 3.) Note that this is true in this function ONLY, since the ranges stored in (*range) are actually packed, skipping those URL components that don't exist. This is why the indices are hard-coded in this function. */ + enum { + scheme_index = 0, + user_index = 1, + password_index = 2, + host_index = 3, + port_index = 4, + path_index = 5, + parameters_index = 6, + query_index = 7, + fragment_index = 8, + }; + CFRange unpackedRanges[MAX_COMPONENTS]; + + CFIndex idx, base_idx = 0; + CFIndex string_length; + UInt32 flags = *theFlags; + Boolean isCompliant; + uint8_t numRanges = 0; + + string_length = cfStringLength; + + // Algorithm is as described in RFC 1808 + // 1: parse the fragment; remainder after left-most "#" is fragment + for (idx = base_idx; idx < string_length; idx++) { + if ('#' == characterArray[idx]) { + flags |= HAS_FRAGMENT; + unpackedRanges[fragment_index].location = idx + 1; + unpackedRanges[fragment_index].length = string_length - (idx + 1); + numRanges ++; + string_length = idx; // remove fragment from parse string + break; + } + } + // 2: parse the scheme + for (idx = base_idx; idx < string_length; idx++) { + UniChar ch = characterArray[idx]; + if (':' == ch) { + flags |= HAS_SCHEME; + unpackedRanges[scheme_index].location = base_idx; + unpackedRanges[scheme_index].length = idx; + numRanges ++; + base_idx = idx + 1; + // optimization for ftp urls + if (idx == 3 && characterArray[0] == 'f' && characterArray[1] == 't' && characterArray[2] == 'p') { + _setSchemeTypeInFlags(&flags, kHasFtpScheme); + } + else if (idx == 4) { + // optimization for http urls + if (characterArray[0] == 'h' && characterArray[1] == 't' && characterArray[2] == 't' && characterArray[3] == 'p') { + _setSchemeTypeInFlags(&flags, kHasHttpScheme); + } + // optimization for file urls + if (characterArray[0] == 'f' && characterArray[1] == 'i' && characterArray[2] == 'l' && characterArray[3] == 'e') { + _setSchemeTypeInFlags(&flags, kHasFileScheme); + } + // optimization for data urls + if (characterArray[0] == 'd' && characterArray[1] == 'a' && characterArray[2] == 't' && characterArray[3] == 'a') { + _setSchemeTypeInFlags(&flags, kHasDataScheme); + } + } + // optimization for https urls + else if (idx == 5 && characterArray[0] == 'h' && characterArray[1] == 't' && characterArray[2] == 't' && characterArray[3] == 'p' && characterArray[3] == 's') { + _setSchemeTypeInFlags(&flags, kHasHttpsScheme); + } + break; + } else if (!scheme_valid(ch)) { + break; // invalid scheme character -- no scheme + } + } + + // Make sure we have an RFC-1808 compliant URL - that's either something without a scheme, or scheme:/(stuff) or scheme://(stuff) + // Strictly speaking, RFC 1808 & 2396 bar "scheme:" (with nothing following the colon); however, common usage + // expects this to be treated identically to "scheme://" - REW, 12/08/03 + if (!(flags & HAS_SCHEME)) { + isCompliant = true; + } else if (base_idx == string_length) { + isCompliant = false; + } else if (characterArray[base_idx] != '/') { + isCompliant = false; + } else { + isCompliant = true; + } + + if (!isCompliant) { + // Clear the fragment flag if it's been set + if (flags & HAS_FRAGMENT) { + flags &= (~HAS_FRAGMENT); + string_length = cfStringLength; + } + (*theFlags) = flags; + packedRanges[scheme_index].location = unpackedRanges[scheme_index].location; + packedRanges[scheme_index].length = unpackedRanges[scheme_index].length; + *numberOfRanges = 1; + } + else { + // URL is 1808-compliant + flags |= IS_DECOMPOSABLE; + + // 3: parse the network location and login + if (2 <= (string_length - base_idx) && '/' == characterArray[base_idx] && '/' == characterArray[base_idx+1]) { + CFIndex base = 2 + base_idx, extent; + for (idx = base; idx < string_length; idx++) { + if ('/' == characterArray[idx] || '?' == characterArray[idx]) { + break; + } + } + extent = idx; + + // net_loc parts extend from base to extent (but not including), which might be to end of string + // net location is ":@:" + if (extent != base) { + for (idx = base; idx < extent; idx++) { + if ('@' == characterArray[idx]) { // there is a user + CFIndex idx2; + flags |= HAS_USER; + numRanges ++; + unpackedRanges[user_index].location = base; // base of the user + for (idx2 = base; idx2 < idx; idx2++) { + if (':' == characterArray[idx2]) { // found a password separator + flags |= HAS_PASSWORD; + numRanges ++; + unpackedRanges[password_index].location = idx2+1; // base of the password + unpackedRanges[password_index].length = idx-(idx2+1); // password extent + unpackedRanges[user_index].length = idx2 - base; // user extent + break; + } + } + if (!(flags & HAS_PASSWORD)) { + // user extends to the '@' + unpackedRanges[user_index].length = idx - base; // user extent + } + base = idx + 1; + break; + } + } + flags |= HAS_HOST; + numRanges ++; + unpackedRanges[host_index].location = base; // base of host + + // base has been advanced past the user and password if they existed + for (idx = base; idx < extent; idx++) { + // IPV6 support (RFC 2732) DCJ June/10/2002 + if ('[' == characterArray[idx]) { // starting IPV6 explicit address + // Find the ']' terminator of the IPv6 address, leave idx pointing to ']' or end + for ( ; idx < extent; ++ idx ) { + if ( ']' == characterArray[idx]) { + flags |= IS_IPV6_ENCODED; + break; + } + } + } + // there is a port if we see a colon. Only the last one is the port, though. + else if ( ':' == characterArray[idx]) { + flags |= HAS_PORT; + numRanges ++; + unpackedRanges[port_index].location = idx+1; // base of port + unpackedRanges[port_index].length = extent - (idx+1); // port extent + unpackedRanges[host_index].length = idx - base; // host extent + break; + } + } + if (!(flags & HAS_PORT)) { + unpackedRanges[host_index].length = extent - base; // host extent + } + } + base_idx = extent; + } + + // 4: parse the query; remainder after left-most "?" is query + for (idx = base_idx; idx < string_length; idx++) { + if ('?' == characterArray[idx]) { + flags |= HAS_QUERY; + numRanges ++; + unpackedRanges[query_index].location = idx + 1; + unpackedRanges[query_index].length = string_length - (idx+1); + string_length = idx; // remove query from parse string + break; + } + } + + // 5: parse the parameters; remainder after left-most ";" is parameters + for (idx = base_idx; idx < string_length; idx++) { + if (';' == characterArray[idx]) { + flags |= HAS_PARAMETERS; + numRanges ++; + unpackedRanges[parameters_index].location = idx + 1; + unpackedRanges[parameters_index].length = string_length - (idx+1); + string_length = idx; // remove parameters from parse string + break; + } + } + + // 6: parse the path; it's whatever's left between string_length & base_idx + if (string_length - base_idx != 0 || (flags & NET_LOCATION_MASK)) + { + // If we have a net location, we are 1808-compliant, and an empty path substring implies a path of "/" + UniChar ch; + Boolean isDir; + CFRange pathRg; + flags |= HAS_PATH; + numRanges ++; + pathRg.location = base_idx; + pathRg.length = string_length - base_idx; + unpackedRanges[path_index] = pathRg; + + if (pathRg.length > 0) { + Boolean sawPercent = FALSE; + for (idx = pathRg.location; idx < string_length; idx++) { + if ('%' == characterArray[idx]) { + sawPercent = TRUE; + break; + } + } +#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI + if (pathRg.length > 6 && characterArray[pathRg.location] == '/' && characterArray[pathRg.location + 1] == '.' && characterArray[pathRg.location + 2] == 'f' && characterArray[pathRg.location + 3] == 'i' && characterArray[pathRg.location + 4] == 'l' && characterArray[pathRg.location + 5] == 'e' && characterArray[pathRg.location + 6] == '/') { + flags |= PATH_HAS_FILE_ID; + } else if (!sawPercent) { + flags |= POSIX_AND_URL_PATHS_MATCH; + } +#elif DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_WINDOWS + if (!sawPercent) { + flags |= POSIX_AND_URL_PATHS_MATCH; + } +#endif + + ch = characterArray[pathRg.location + pathRg.length - 1]; + if (ch == '/') { + isDir = true; + } else if (ch == '.') { + if (pathRg.length == 1) { + isDir = true; + } else { + ch = characterArray[pathRg.location + pathRg.length - 2]; + if (ch == '/') { + isDir = true; + } else if (ch != '.') { + isDir = false; + } else if (pathRg.length == 2) { + isDir = true; + } else { + isDir = (characterArray[pathRg.location + pathRg.length - 3] == '/'); + } + } + } else { + isDir = false; + } + } else { + isDir = (baseURL != NULL) ? CFURLHasDirectoryPath(baseURL) : false; + } + if (isDir) { + flags |= IS_DIRECTORY; + } + } + + (*theFlags) = flags; + *numberOfRanges = numRanges; + numRanges = 0; + for (idx = 0, flags = 1; flags != (1<<9); flags = (flags<<1), idx ++) { + if ((*theFlags) & flags) { + packedRanges[numRanges] = unpackedRanges[idx]; + numRanges ++; + } + } + } +} +#endif // CFURL_INCLUDE_PARSE_COMPONENTS + +/* + static Boolean scanCharactersCString(CFAllocatorRef alloc, CFMutableStringRef *escapedString, UInt32 *flags, const char *characterArray, Boolean useCString, CFIndex base, CFIndex end, CFIndex *mark, UInt32 componentFlag, CFStringEncoding encoding) + static Boolean scanCharactersUString(CFAllocatorRef alloc, CFMutableStringRef *escapedString, UInt32 *flags, const UniChar *characterArray, Boolean useCString, CFIndex base, CFIndex end, CFIndex *mark, UInt32 componentFlag, CFStringEncoding encoding) + */ +#ifdef CFURL_INCLUDE_SCAN_CHARACTERS // defined when we want this block of code included +{ + CFIndex idx; + Boolean sawIllegalChar = false; + for (idx = base; idx < end; idx ++) { + Boolean shouldEscape; + UniChar ch = characterArray[idx]; + if (isURLLegalCharacter(ch)) { + if ((componentFlag == HAS_USER || componentFlag == HAS_PASSWORD) && (ch == '/' || ch == '?' || ch == '@')) { + shouldEscape = true; + } else { + shouldEscape = false; + } + } else if (ch == '%' && idx + 2 < end && isHexDigit(characterArray[idx + 1]) && isHexDigit(characterArray[idx+2])) { + shouldEscape = false; + } else if (componentFlag == HAS_HOST && ((idx == base && ch == '[') || (idx == end-1 && ch == ']'))) { + shouldEscape = false; + } else { + shouldEscape = true; + } + if (shouldEscape) { + sawIllegalChar = true; + if (componentFlag && flags) { + *flags |= componentFlag; + } + if (!*escapedString) { + *escapedString = CFStringCreateMutable(alloc, 0); + } + if (useCString) { + CFStringRef tempString = CFStringCreateWithBytes(alloc, (uint8_t *)&(characterArray[*mark]), idx - *mark, kCFStringEncodingISOLatin1, false); + CFStringAppend(*escapedString, tempString); + CFRelease(tempString); + } else { + CFStringAppendCharacters(*escapedString, (const UniChar *)&(characterArray[*mark]), idx - *mark); + } + *mark = idx + 1; + _appendPercentEscapesForCharacter(ch, encoding, *escapedString); // This can never fail because anURL->_string was constructed from the encoding passed in + } + } + return sawIllegalChar; +} +#endif // CFURL_INCLUDE_SCAN_CHARACTERS diff --git a/include/CoreFoundation/CFURLAccess.h b/include/CoreFoundation/CFURLAccess.h new file mode 100644 index 0000000..6986e39 --- /dev/null +++ b/include/CoreFoundation/CFURLAccess.h @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFURLAccess.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. + + 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. +*/ + +#if !defined(__COREFOUNDATION_CFURLACCESS__) +#define __COREFOUNDATION_CFURLACCESS__ 1 + +#include +#include +#include +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + + + +/* Attempts to read the data and properties for the given URL. If +only interested in one of the resourceData and properties, pass NULL +for the other. If properties is non-NULL and desiredProperties is +NULL, then all properties are fetched. Returns success or failure; +note that as much work as possible is done even if false is returned. +So for instance if one property is not available, the others are +fetched anyway. errorCode is set to 0 on success, and some other +value on failure. If non-NULL, it is the caller 's responsibility +to release resourceData and properties. + + Apple reserves for its use all negative error code values; these +values represent errors common to any scheme. Scheme-specific error +codes should be positive, non-zero, and should be used only if one of +the predefined Apple error codes does not apply. Error codes should +be publicized and documented with the scheme-specific properties. + +NOTE: When asking for the resource data, this call will allocate the entire +resource in memory. This can be very expensive, depending on the size of the +resource (file). Please use CFStream or other techniques if you are downloading +large files. + +*/ +/* Deprecated -- see top of this file for suggested replacement classes */ +CF_EXPORT +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."); + +/* Attempts to write the given data and properties to the given URL. +If dataToWrite is NULL, only properties are written out (use +CFURLDestroyResource() to delete a resource). Properties not present +in propertiesToWrite are left unchanged, hence if propertiesToWrite +is NULL or empty, the URL's properties are not changed at all. +Returns success or failure; errorCode is set as for +CFURLCreateDataAndPropertiesFromResource(), above. +*/ +/* Deprecated -- see top of this file for suggested replacement classes */ +CF_EXPORT +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."); + +/* Destroys the resource indicated by url. +Returns success or failure; errorCode set as above. +*/ +/* Deprecated -- see top of this file for suggested replacement classes */ +CF_EXPORT +Boolean CFURLDestroyResource(CFURLRef url, SInt32 *errorCode) CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLGetFileSystemRepresentation and removefile(3) instead."); + +/* Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource(). +Returns NULL on error and sets errorCode accordingly. +*/ +/* Deprecated -- see top of this file for suggested replacement classes */ +CF_EXPORT +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."); + + +/* Common error codes (returned only by the older APIs that predate CFError) */ +typedef CF_ENUM(CFIndex, CFURLError) { + kCFURLUnknownError = -10L, + kCFURLUnknownSchemeError = -11L, + kCFURLResourceNotFoundError = -12L, + kCFURLResourceAccessViolationError = -13L, + kCFURLRemoteHostUnavailableError = -14L, + kCFURLImproperArgumentsError = -15L, + kCFURLUnknownPropertyKeyError = -16L, + kCFURLPropertyKeyUnavailableError = -17L, + kCFURLTimeoutError = -18L +} CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0); + +/* Older property keys */ + +CF_EXPORT +const CFStringRef kCFURLFileExists CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLResourceIsReachable instead."); +CF_EXPORT +const CFStringRef kCFURLFileDirectoryContents CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use the CFURLEnumerator API instead."); +CF_EXPORT +const CFStringRef kCFURLFileLength CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLFileSizeKey instead."); +CF_EXPORT +const CFStringRef kCFURLFileLastModificationTime CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLContentModificationDateKey instead."); +CF_EXPORT +const CFStringRef kCFURLFilePOSIXMode CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLFileSecurityKey and then the CFFileSecurity API instead."); +CF_EXPORT +const CFStringRef kCFURLFileOwnerID CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use CFURLCopyResourcePropertyForKey with kCFURLFileSecurityKey and then the CFFileSecurity API instead."); +CF_EXPORT +const CFStringRef kCFURLHTTPStatusCode CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use NSHTTPURLResponse methods instead."); +CF_EXPORT +const CFStringRef kCFURLHTTPStatusLine CF_DEPRECATED(10_0, 10_9, 2_0, 7_0, "Use NSHTTPURLResponse methods instead."); + +/* The value of kCFURLFileExists is a CFBoolean */ +/* The value of kCFURLFileDirectoryContents is a CFArray containing CFURLs. An empty array means the directory exists, but is empty */ +/* The value of kCFURLFileLength is a CFNumber giving the file's length in bytes */ +/* The value of kCFURLFileLastModificationTime is a CFDate */ +/* The value of kCFURLFilePOSIXMode is a CFNumber as given in stat.h */ +/* The value of kCFURLFileOwnerID is a CFNumber representing the owner's uid */ + +/* 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 */ +/* The value of kCFURLHTTPStatusCode is a CFNumber */ +/* The value of kCFURLHTTPStatusLine is a CFString */ + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFURLACCESS__ */ + diff --git a/include/CoreFoundation/CFURLEnumerator.h b/include/CoreFoundation/CFURLEnumerator.h new file mode 100644 index 0000000..dfba61a --- /dev/null +++ b/include/CoreFoundation/CFURLEnumerator.h @@ -0,0 +1,42 @@ +#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION +#if !defined(__COREFOUNDATION_CFURLENUMERATOR__) +#define __COREFOUNDATION_CFURLENUMERATOR__ 1 + +#include +#include +#include +#include + +CF_EXTERN_C_BEGIN + +typedef const struct __CFURLEnumerator *CFURLEnumeratorRef; + +typedef CF_OPTIONS(CFOptionFlags, CFURLEnumeratorOptions) { + kCFURLEnumeratorDefaultBehavior = 0, + kCFURLEnumeratorDescendRecursively = 1UL << 0, + kCFURLEnumeratorSkipInvisibles = 1UL << 1, + kCFURLEnumeratorGenerateFileReferenceURLs = 1UL << 2, + kCFURLEnumeratorSkipPackageContents = 1UL << 3, + kCFURLEnumeratorIncludeDirectoriesPreOrder = 1UL << 4, + kCFURLEnumeratorIncludeDirectoriesPostOrder = 1UL << 5, +}; + +typedef CF_ENUM(CFIndex, CFURLEnumeratorResult) { + kCFURLEnumeratorSuccess = 1, + kCFURLEnumeratorEnd = 2, + kCFURLEnumeratorError = 3, + kCFURLEnumeratorDirectoryPostOrderSuccess = 4, +}; + +CF_EXPORT CFTypeID CFURLEnumeratorGetTypeID(void); +CF_EXPORT CFURLEnumeratorRef CFURLEnumeratorCreateForDirectoryURL(CFAllocatorRef alloc, CFURLRef directoryURL, CFURLEnumeratorOptions option, CFArrayRef propertyKeys); +CF_EXPORT CFURLEnumeratorRef CFURLEnumeratorCreateForMountedVolumes(CFAllocatorRef alloc, CFURLEnumeratorOptions option, CFArrayRef propertyKeys); +CF_EXPORT CFURLEnumeratorResult CFURLEnumeratorGetNextURL(CFURLEnumeratorRef enumerator, CFURLRef *url, CFErrorRef *error); +CF_EXPORT void CFURLEnumeratorSkipDescendents(CFURLEnumeratorRef enumerator); +CF_EXPORT CFIndex CFURLEnumeratorGetDescendentLevel(CFURLEnumeratorRef enumerator); +CF_EXPORT Boolean CFURLEnumeratorGetSourceDidChange(CFURLEnumeratorRef enumerator); + +CF_EXTERN_C_END + +#endif +#endif diff --git a/include/CoreFoundation/CFURLPriv.h b/include/CoreFoundation/CFURLPriv.h new file mode 100644 index 0000000..b90699a --- /dev/null +++ b/include/CoreFoundation/CFURLPriv.h @@ -0,0 +1,692 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFURLPriv.h + Copyright (c) 2008-2014, Apple Inc. All rights reserved. + Responsibility: Jim Luther/Chris Linn + */ + +#if !defined(__COREFOUNDATION_CFURLPRIV__) +#define __COREFOUNDATION_CFURLPRIV__ 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if TARGET_OS_MAC +#include +#endif + +CF_EXTERN_C_BEGIN + +// The kCFURLxxxxError enums are error codes in the Cocoa error domain and they mirror the exact same codes in (i.e. kCFURLReadNoPermissionError = NSFileReadNoPermissionError = 257). They were added to CFURLPriv.h so that CarbonCore and later CoreServicesInternal could return these error codes in the Cocoa error domain. If your code links with Foundation, you should use the codes in , not these codes. +enum { + // Resource I/O related errors, with kCFErrorURLKey containing URL + kCFURLNoSuchResourceError = 4, // Attempt to do a file system operation on a non-existent file + kCFURLResourceLockingError = 255, // Couldn't get a lock on file + kCFURLReadUnknownError = 256, // Read error (reason unknown) + kCFURLReadNoPermissionError = 257, // Read error (permission problem) + kCFURLReadInvalidResourceNameError = 258, // Read error (invalid file name) + kCFURLReadCorruptResourceError = 259, // Read error (file corrupt, bad format, etc) + kCFURLReadNoSuchResourceError = 260, // Read error (no such file) + kCFURLReadInapplicableStringEncodingError = 261, // Read error (string encoding not applicable) also kCFStringEncodingErrorKey + kCFURLReadUnsupportedSchemeError = 262, // Read error (unsupported URL scheme) + kCFURLReadTooLargeError = 263, // Read error (file too large) + kCFURLReadUnknownStringEncodingError = 264, // Read error (string encoding of file contents could not be determined) + kCFURLWriteUnknownError = 512, // Write error (reason unknown) + kCFURLWriteNoPermissionError = 513, // Write error (permission problem) + kCFURLWriteInvalidResourceNameError = 514, // Write error (invalid file name) + kCFURLWriteInapplicableStringEncodingError = 517, // Write error (string encoding not applicable) also kCFStringEncodingErrorKey + kCFURLWriteUnsupportedSchemeError = 518, // Write error (unsupported URL scheme) + kCFURLWriteOutOfSpaceError = 640, // Write error (out of storage space) + kCFURLWriteVolumeReadOnlyError = 642, // Write error (readonly volume) +} CF_ENUM_AVAILABLE(10_5, 2_0); + + +/* + Private File System Property Keys +*/ +CF_EXPORT const CFStringRef _kCFURLPathKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLPathKey or NSURLPathKey public property keys */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIDKey CF_AVAILABLE(10_6, 4_0); + /* Volume ID (CFNumber) */ + +CF_EXPORT const CFStringRef _kCFURLInodeNumberKey CF_AVAILABLE(10_6, 4_0); + /* 64-bit inode number (the inode number from the file system) (CFNumber) */ + +CF_EXPORT const CFStringRef _kCFURLFileIDKey CF_AVAILABLE(10_6, 4_0); + /* 64-bit file ID (for tracking a file by ID. This may or may not be the inode number) (CFNumber) */ + +CF_EXPORT const CFStringRef _kCFURLParentDirectoryIDKey CF_AVAILABLE(10_6, 4_0); + /* 64-bit file ID (for tracking a parent directory by ID. This may or may not be the inode number) (CFNumber) */ + +CF_EXPORT const CFStringRef _kCFURLDistinctLocalizedNameKey CF_AVAILABLE(10_6, 4_0); + /* The localized name, if it is distinct from the real name. Otherwise, NULL (CFString) */ + +CF_EXPORT const CFStringRef _kCFURLNameExtensionKey CF_AVAILABLE(10_6, 4_0); + /* The name extension (CFString) */ + +CF_EXPORT const CFStringRef _kCFURLFinderInfoKey CF_AVAILABLE(10_6, 4_0); + /* A 16-byte Finder Info structure immediately followed by a 16-byte Extended Finder Info structure (CFData) */ + +CF_EXPORT const CFStringRef _kCFURLIsCompressedKey CF_AVAILABLE(10_6, 4_0); + /* True if resource's data is transparently compressed by the system on its storage device (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLIsApplicationKey CF_AVAILABLE(10_6, 4_0); + /* True if resource is an application (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLCanSetHiddenExtensionKey CF_AVAILABLE(10_6, 4_0); + /* True if the filename extension can be hidden or unhidden (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLIsReadableKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLIsReadableKey or NSURLIsReadableKey public property keys */ +/* never implemented and scheduled for removal in 10.10/8.0 */CF_EXPORT const CFStringRef _kCFURLUserCanReadKey CF_DEPRECATED(10_0, 10_6, 2_0, 4_0); + +CF_EXPORT const CFStringRef _kCFURLIsWriteableKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLIsWritableKey or NSURLIsWritableKey public property keys */ +/* never implemented and scheduled for removal in 10.10/8.0 */CF_EXPORT const CFStringRef _kCFURLUserCanWriteKey CF_DEPRECATED(10_0, 10_6, 2_0, 4_0); + +CF_EXPORT const CFStringRef _kCFURLIsExecutableKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLIsExecutableKey or NSURLIsExecutableKey public property keys */ +/* never implemented and scheduled for removal in 10.10/8.0 */CF_EXPORT const CFStringRef _kCFURLUserCanExecuteKey CF_DEPRECATED(10_0, 10_6, 2_0, 4_0); + +CF_EXPORT const CFStringRef _kCFURLParentDirectoryIsVolumeRootKey CF_AVAILABLE(10_6, 4_0); + /* True if the parent directory is the root of a volume (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLFileSecurityKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLFileSecurityKey or NSURLFileSecurityKey public property keys */ + +CF_EXPORT const CFStringRef _kCFURLFileSizeOfResourceForkKey CF_AVAILABLE(10_6, 4_0); + /* Size in bytes of the resource fork (CFNumber) */ + +CF_EXPORT const CFStringRef _kCFURLFileAllocatedSizeOfResourceForkKey CF_AVAILABLE(10_6, 4_0); + /* Size in bytes of the blocks allocated for the resource fork (CFNumber) */ + +CF_EXPORT const CFStringRef _kCFURLEffectiveIconImageDataKey CF_AVAILABLE(10_6, 4_0); + /* Icon image data, i.e. raw pixel data (CFData) */ + +CF_EXPORT const CFStringRef _kCFURLTypeBindingKey CF_AVAILABLE(10_10, 8_0); + /* Type binding for icon (Read-only, value type CFData) */ + +CF_EXPORT const CFStringRef _kCFURLCustomIconImageDataKey CF_AVAILABLE(10_6, 4_0); + /* Icon image data of the item's custom icon, if any (CFData) */ + +CF_EXPORT const CFStringRef _kCFURLEffectiveIconFlattenedReferenceDataKey CF_AVAILABLE(10_6, 4_0); + /* Icon flattened reference, suitable for cheaply sharing the effective icon reference across processess (CFData) */ + +CF_EXPORT const CFStringRef _kCFURLBundleIdentifierKey CF_AVAILABLE(10_6, 4_0); + /* If resource is a bundle, the bundle identifier (CFString) */ + +CF_EXPORT const CFStringRef _kCFURLVersionKey CF_AVAILABLE(10_6, 4_0); + /* If resource is a bundle, the bundle version (CFBundleVersion) as a string (CFString) */ + +CF_EXPORT const CFStringRef _kCFURLShortVersionStringKey CF_AVAILABLE(10_6, 4_0); + /* If resource is a bundle, the bundle short version (CFBundleShortVersionString) as a string (CFString) */ + +CF_EXPORT const CFStringRef _kCFURLOwnerIDKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal later in 10.9/7.0 since it is unused - Use the kCFURLFileSecurityKey or NSURLFileSecurityKey public property keys and CFFileSecurityGetOwner() */ + +CF_EXPORT const CFStringRef _kCFURLGroupIDKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal later in 10.9/7.0 since it is unused - Use the kCFURLFileSecurityKey or NSURLFileSecurityKey public property keys and CFFileSecurityGetGroup() */ + +CF_EXPORT const CFStringRef _kCFURLStatModeKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal later in 10.9/7.0 since it is unused - Use the kCFURLFileSecurityKey or NSURLFileSecurityKey public property keys and CFFileSecurityGetMode() */ + +CF_EXPORT const CFStringRef _kCFURLLocalizedNameDictionaryKey CF_AVAILABLE(10_7, NA); + /* For items with localized display names, the dictionary of all available localizations. The keys are the cannonical locale strings for the available localizations. (CFDictionary) */ + +CF_EXPORT const CFStringRef _kCFURLLocalizedTypeDescriptionDictionaryKey CF_AVAILABLE(10_7, NA); + /* The dictionary of all available localizations of the item kind string. The keys are the cannonical locale strings for the available localizations. (CFDictionary) */ + +CF_EXPORT const CFStringRef _kCFURLApplicationCategoriesKey CF_AVAILABLE(10_7, NA); + /* The array of category UTI strings associated with the url. (CFArray) */ + +CF_EXPORT const CFStringRef _kCFURLApplicationHighResolutionModeIsMagnifiedKey CF_AVAILABLE(10_7, NA); + /* True if the app runs with magnified 1x graphics on a 2x display (Per-user, CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLCanSetApplicationHighResolutionModeIsMagnifiedKey CF_AVAILABLE(10_7, NA); + /* True if the app can run in either magnified or native resolution modes (Read only, CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLWriterBundleIdentifierKey CF_AVAILABLE(10_8, NA); + /* The bundle identifier of the process writing to this object (Read-write, value type CFString) */ + +CF_EXPORT const CFStringRef _kCFURLApplicationNapIsDisabledKey CF_AVAILABLE(10_9, NA); + /* True if app nap is disabled (Applications only, Per-user, CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLCanSetApplicationNapIsDisabledKey CF_AVAILABLE(10_9, NA); + /* True if the ApplicationNapIsDisabled property value can be changed (Applications only, Read only, CFBoolean) */ + +/* Additional volume properties */ + +CF_EXPORT const CFStringRef _kCFURLVolumeRefNumKey CF_AVAILABLE(10_6, 4_0); + /* The Carbon File Manager's FSVolumeRefNum for the resource volume (CFNumber) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeUUIDStringKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeUUIDStringKey or NSURLVolumeUUIDStringKey public property keys */ + +CF_EXPORT const CFStringRef _kCFURLVolumeCreationDateKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeCreationDateKey or NSURLVolumeCreationDateKey public property keys */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsLocalKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsLocalKey or NSURLVolumeIsLocalKey public property keys */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsAutomountKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsAutomountedKey or NSURLVolumeIsAutomountedKey public property keys */ + +CF_EXPORT const CFStringRef _kCFURLVolumeDontBrowseKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsBrowsableKey or NSURLVolumeIsBrowsableKey public property keys (Note: value is inverse of _kCFURLVolumeDontBrowseKey) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsReadOnlyKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsReadOnlyKey or NSURLVolumeIsReadOnlyKey public property keys */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsQuarantinedKey CF_AVAILABLE(10_6, 4_0); + /* Mounted quarantined (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsEjectableKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsEjectableKey or NSURLVolumeIsEjectableKey public property keys */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsRemovableKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsRemovableKey or NSURLVolumeIsRemovableKey public property keys */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsInternalKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsInternalKey or NSURLVolumeIsInternalKey public property keys (Note: this has slightly different behavior than the public VolumeIsInternal key) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsExternalKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeIsInternalKey or NSURLVolumeIsInternalKey public property keys (Note: this has slightly different behavior than the public VolumeIsInternal key) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsDiskImageKey CF_AVAILABLE(10_6, 4_0); + /* Volume is a mounted disk image (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLDiskImageBackingURLKey CF_AVAILABLE(10_6, 4_0); + /* If volume is a mounted disk image, the URL of the backing disk image (CFURL) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsFileVaultKey CF_AVAILABLE(10_6, 4_0); + /* Volume uses File Vault encryption (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsiDiskKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - there are no more iDisks */ + +CF_EXPORT const CFStringRef _kCFURLVolumeiDiskUserNameKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - there are no more iDisks */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsLocaliDiskMirrorKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - there are no more iDisks */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsiPodKey CF_AVAILABLE(10_6, 4_0); + /* Volume is on an iPod (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsCDKey CF_AVAILABLE(10_6, 4_0); + /* Volume is a CD (audio or CD-ROM). (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsDVDKey CF_AVAILABLE(10_6, 4_0); + /* Volume is a DVD (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsDeviceFileSystemKey CF_AVAILABLE(10_7, 5_0); + /* Volume is devfs (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIsHFSStandardKey CF_AVAILABLE(10_6, 4_0); + /* Volume is HFS standard (which includes AFP volumes). Directory IDs, but not file IDs, can be looked up. (CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIOMediaIconFamilyNameKey CF_AVAILABLE(10_9, NA); + /* Volume's IOMediaIconFamilyName. (CFStringRef) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeIOMediaIconBundleIdentifierKey CF_AVAILABLE(10_9, NA); + /* Volume's IOMediaIconBundleIdentifier. (CFStringRef) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeQuarantinePropertiesKey CF_AVAILABLE(10_10, NA); + /* The quarantine properties for the volume on which the resource resides as defined in LSQuarantine.h.=To remove quarantine information from a volume, pass kCFNull as the value when setting this property. (Read-write, value type CFDictionary) */ + +CF_EXPORT const CFStringRef _kCFURLVolumeOpenFolderURLKey CF_AVAILABLE(10_10, NA); + /* Returns a URL to the folder the Finder should open when a HFS volume is mounted, or NULL if there is none. (Read-only, value type CFURL) */ + +CF_EXPORT const CFStringRef _kCFURLResolvedFromBookmarkDataKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal later in 10.9/7.0 since it is unused (*/ + +CF_EXPORT const CFStringRef _kCFURLVolumeMountPointStringKey CF_AVAILABLE(10_6, 4_0); + /* the volume mountpoint string (Read-only, value type CFString) */ + +CF_EXPORT const CFStringRef _kCFURLCompleteMountURLKey CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + /* Deprecated and scheduled for removal in 10.10/8.0 - Use the kCFURLVolumeURLForRemountingKey or NSURLVolumeURLForRemountingKey public property keys */ + +CF_EXPORT const CFStringRef _kCFURLUbiquitousItemDownloadRequestedKey CF_AVAILABLE(10_9, 7_0); + /* Is this Ubiquity item scheduled for download? (this is also true for items that are already downloaded). Use startDownloadingUbiquitousItemAtURL:error: to make this true (Read-only, value type CFBoolean) */ + +CF_EXPORT const CFStringRef _kCFURLCloudDocsPlaceholderDictionaryKey CF_AVAILABLE(10_10, 8_0); + /* Returns the placeholder dictionary for a side-fault file (Read-only, value type CFDictionary) */ + +CF_EXPORT const CFStringRef _kCFURLCloudDocsPlaceholderLogicalNameKey CF_AVAILABLE(10_10, 8_0); + /* Returns the placeholder dictionary for a side-fault file (Read-only, value type CFString) */ + +// Temporary holding place for future API. + +CF_EXPORT const CFStringRef kCFURLUbiquitousItemDownloadRequestedKey CF_AVAILABLE(10_9, 7_0); +/* Is this Ubiquity item scheduled for download? (this is also true for items that are already downloaded). Use startDownloadingUbiquitousItemAtURL:error: to make this true (Read-only, value type CFBoolean) */ + +CF_EXPORT const CFStringRef kCFURLUbiquitousItemContainerDisplayNameKey CF_AVAILABLE(10_10, 8_0); + /* Returns the localized name of the ubiquity container that contains this item (Read-only, value type CFString) */ + +CF_EXPORT const CFStringRef kCFURLUbiquitousItemIsSharedKey; // true if the ubiquitous item is shared. (Read-only, value type boolean NSNumber) + +CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemRoleKey /*CF_AVAILABLE(10_11, 9_0)*/; // returns the current user's role for this shared item, or nil if not shared. (Read-only, value type NSString). Possible values below. +CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemRoleOwner /*CF_AVAILABLE(10_11, 9_0)*/; // the current user is the owner of this shared item. +CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemRoleParticipant /*CF_AVAILABLE(10_11, 9_0)*/; // the current user is a participant of this shared item. + +CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemOwnerNameKey /*CF_AVAILABLE(10_11, 9_0)*/; // returns the name of the owner of a shared item, or nil if the current user. (Read-only, value type NSString) + +CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemPermissionsKey /*CF_AVAILABLE(10_11, 9_0)*/; // returns the current user's permissions for this shared item. (Read-only, value type NSString). Possible values below. +CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemPermissionsReadOnly /*CF_AVAILABLE(10_11, 9_0)*/; // the user is only allowed to read this item +CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemPermissionsReadWrite /*CF_AVAILABLE(10_11, 9_0)*/; // the user is allowed to both read and write this item + +// Deprecated. Will be removed. +CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemReadOnlyPermissions /*CF_AVAILABLE(10_11, 9_0)*/; // the user is only allowed to read this item +CF_EXPORT const CFStringRef kCFURLUbiquitousSharedItemReadWritePermissions /*CF_AVAILABLE(10_11, 9_0)*/; // the user is allowed to both read and write this item + + +// these keys are defined here, not in CFURL.h, because they return NSImage values which can only be used by Foundation +CF_EXPORT const CFStringRef kCFURLThumbnailDictionaryKey CF_AVAILABLE(10_10, 8_0); +CF_EXPORT const CFStringRef kCFURLThumbnailKey CF_AVAILABLE(10_10, 8_0); +// The values of thumbnails in the dictionary returned by NSURLThumbnailDictionaryKey +CF_EXPORT const CFStringRef kCFThumbnail1024x1024SizeKey CF_AVAILABLE(10_10, 8_0); + + +/* + Some common boolean properties can be accessed as a bitfield + for better performance -- see _CFURLGetResourcePropertyFlags() and + _CFURLCopyResourcePropertyValuesAndFlags(), below. + */ +enum { + kCFURLResourceIsRegularFile = 0x00000001, + kCFURLResourceIsDirectory = 0x00000002, + kCFURLResourceIsSymbolicLink = 0x00000004, + kCFURLResourceIsVolume = 0x00000008, + kCFURLResourceIsPackage = 0x00000010, + kCFURLResourceIsSystemImmutable = 0x00000020, + kCFURLResourceIsUserImmutable = 0x00000040, + kCFURLResourceIsHidden = 0x00000080, + kCFURLResourceHasHiddenExtension = 0x00000100, + kCFURLResourceIsApplication = 0x00000200, + kCFURLResourceIsCompressed = 0x00000400, + kCFURLResourceIsSystemCompressed CF_ENUM_DEPRECATED(10_6, 10_9, 4_0, 7_0) + = 0x00000400, /* Deprecated and scheduled for removal in 10.10/8.0 - Use kCFURLResourceIsCompressed */ + kCFURLCanSetHiddenExtension = 0x00000800, + kCFURLResourceIsReadable = 0x00001000, + kCFURLResourceIsWriteable = 0x00002000, + kCFURLResourceIsExecutable = 0x00004000, /* execute files or search directories */ + kCFURLIsAliasFile = 0x00008000, + kCFURLIsMountTrigger = 0x00010000, +}; +typedef unsigned long long CFURLResourcePropertyFlags; + + +/* + _CFURLGetResourceFlags - Returns a bit array of resource flags in the "flags" + output parameter. Only flags whose corresponding bits are set in the "mask" parameter + are valid in the output bit array. Returns true on success, false if an error occurs. + Optional output error: the error is set to a valid CFErrorRef if and only if the function + returns false. A valid output error must be released by the caller. + */ +CF_EXPORT +Boolean _CFURLGetResourcePropertyFlags(CFURLRef url, CFURLResourcePropertyFlags mask, CFURLResourcePropertyFlags *flags, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + + +/* + File resource properties which can be obtained with _CFURLCopyFilePropertyValuesAndFlags(). + */ +typedef CF_OPTIONS(unsigned long long, CFURLFilePropertyBitmap) { + kCFURLName = 0x0000000000000001, + kCFURLLinkCount = 0x0000000000000002, + kCFURLVolumeIdentifier = 0x0000000000000004, + kCFURLObjectIdentifier = 0x0000000000000008, + kCFURLCreationDate = 0x0000000000000010, + kCFURLContentModificationDate = 0x0000000000000020, + kCFURLAttributeModificationDate = 0x0000000000000040, + kCFURLFileSize = 0x0000000000000080, + kCFURLFileAllocatedSize = 0x0000000000000100, + kCFURLFileSizeOfResourceFork = 0x0000000000000200, + kCFURLFileAllocatedSizeOfResourceFork = 0x0000000000000400, + kCFURLFinderInfo = 0x0000000000000800, + kCFURLFileSecurity = 0x0000000000001000, +}; + +/* + The structure where _CFURLCopyFilePropertyValuesAndFlags() returns file resource properties. + */ +struct _CFURLFilePropertyValues { + CFStringRef name; /* you are responsible for releasing this if you ask for it and get it */ + uint32_t linkCount; + uint64_t volumeIdentifier; + uint64_t objectIdentifier; + CFAbsoluteTime creationDate; + CFAbsoluteTime contentModificationDate; + CFAbsoluteTime attributeModificationDate; + uint64_t fileSize; + uint64_t fileAllocatedSize; + uint64_t fileSizeOfResourceFork; + uint64_t fileAllocatedSizeOfResourceFork; + uint8_t finderInfo[32]; + CFFileSecurityRef fileSecurity; /* you are responsible for releasing this if you ask for it and get it */ +}; +typedef struct _CFURLFilePropertyValues _CFURLFilePropertyValues; + +/* + _CFURLCopyResourcePropertyValuesAndFlags - Returns property values as simple types + whenever possible. Returns a bit array of resource flags in the "flags" + output parameter. Only flags whose corresponding bits are set in the "mask" parameter + are valid in the output bit array. Returns true on success, false if an error occurs. + Optional output error: the error is set to a valid CFErrorRef if and only if the function + returns false. A valid output error must be released by the caller. + */ +CF_EXPORT +Boolean _CFURLCopyResourcePropertyValuesAndFlags( CFURLRef url, CFURLFilePropertyBitmap requestProperties, CFURLFilePropertyBitmap *actualProperties, struct _CFURLFilePropertyValues *properties, CFURLResourcePropertyFlags propertyFlagsMask, CFURLResourcePropertyFlags *propertyFlags, CFErrorRef *error) CF_AVAILABLE(10_7, 4_0); + +/* + Volume property flags + */ +typedef CF_OPTIONS(unsigned long long, CFURLVolumePropertyFlags) { + kCFURLVolumeIsLocal = 0x1LL, // Local device (vs. network device) + kCFURLVolumeIsAutomount = 0x2LL, // Mounted by the automounter + kCFURLVolumeDontBrowse = 0x4LL, // Hidden from user browsing + kCFURLVolumeIsReadOnly = 0x8LL, // Mounted read-only + kCFURLVolumeIsQuarantined = 0x10LL, // Mounted with quarantine bit + kCFURLVolumeIsEjectable = 0x20LL, + kCFURLVolumeIsRemovable = 0x40LL, + kCFURLVolumeIsInternal = 0x80LL, + kCFURLVolumeIsExternal = 0x100LL, + kCFURLVolumeIsDiskImage = 0x200LL, + kCFURLVolumeIsFileVault = 0x400LL, + kCFURLVolumeIsLocaliDiskMirror CF_ENUM_DEPRECATED(10_6, 10_9, 4_0, 7_0) + = 0x800LL, // Deprecated and scheduled for removal in 10.10/8.0 - there are no more iDisks + kCFURLVolumeIsiPod = 0x1000LL, + kCFURLVolumeIsiDisk CF_ENUM_DEPRECATED(10_6, 10_9, 4_0, 7_0) + = 0x2000LL, // Deprecated and scheduled for removal in 10.10/8.0 - there are no more iDisks + kCFURLVolumeIsCD = 0x4000LL, + kCFURLVolumeIsDVD = 0x8000LL, + kCFURLVolumeIsDeviceFileSystem = 0x10000LL, + kCFURLVolumeIsTimeMachine CF_ENUM_AVAILABLE_MAC(10_9) + = 0x20000LL, + kCFURLVolumeIsAirport CF_ENUM_AVAILABLE_MAC(10_9) + = 0x40000LL, + kCFURLVolumeIsVideoDisk CF_ENUM_AVAILABLE_MAC(10_9) + = 0x80000LL, + kCFURLVolumeIsDVDVideo CF_ENUM_AVAILABLE_MAC(10_9) + = 0x100000LL, + kCFURLVolumeIsBDVideo CF_ENUM_AVAILABLE_MAC(10_9) + = 0x200000LL, + kCFURLVolumeIsMobileTimeMachine CF_ENUM_AVAILABLE_MAC(10_9) + = 0x400000LL, + kCFURLVolumeIsNetworkOptical CF_ENUM_AVAILABLE_MAC(10_9) + = 0x800000LL, + kCFURLVolumeIsBeingRepaired CF_ENUM_AVAILABLE_MAC(10_9) + = 0x1000000LL, + kCFURLVolumeIsBeingUnmounted CF_ENUM_AVAILABLE_MAC(10_9) + = 0x2000000LL, + +// IMPORTANT: The values of the following flags must stay in sync with the +// VolumeCapabilities flags in CarbonCore (FileIDTreeStorage.h) + kCFURLVolumeSupportsPersistentIDs = 0x100000000LL, + kCFURLVolumeSupportsSearchFS = 0x200000000LL, + kCFURLVolumeSupportsExchange = 0x400000000LL, + // reserved 0x800000000LL, + kCFURLVolumeSupportsSymbolicLinks = 0x1000000000LL, + kCFURLVolumeSupportsDenyModes = 0x2000000000LL, + kCFURLVolumeSupportsCopyFile = 0x4000000000LL, + kCFURLVolumeSupportsReadDirAttr = 0x8000000000LL, + kCFURLVolumeSupportsJournaling = 0x10000000000LL, + kCFURLVolumeSupportsRename = 0x20000000000LL, + kCFURLVolumeSupportsFastStatFS = 0x40000000000LL, + kCFURLVolumeSupportsCaseSensitiveNames = 0x80000000000LL, + kCFURLVolumeSupportsCasePreservedNames = 0x100000000000LL, + kCFURLVolumeSupportsFLock = 0x200000000000LL, + kCFURLVolumeHasNoRootDirectoryTimes = 0x400000000000LL, + kCFURLVolumeSupportsExtendedSecurity = 0x800000000000LL, + kCFURLVolumeSupports2TBFileSize = 0x1000000000000LL, + kCFURLVolumeSupportsHardLinks = 0x2000000000000LL, + kCFURLVolumeSupportsMandatoryByteRangeLocks = 0x4000000000000LL, + kCFURLVolumeSupportsPathFromID = 0x8000000000000LL, + // reserved 0x10000000000000LL, + kCFURLVolumeIsJournaling = 0x20000000000000LL, + kCFURLVolumeSupportsSparseFiles = 0x40000000000000LL, + kCFURLVolumeSupportsZeroRuns = 0x80000000000000LL, + kCFURLVolumeSupportsVolumeSizes = 0x100000000000000LL, + kCFURLVolumeSupportsRemoteEvents = 0x200000000000000LL, + kCFURLVolumeSupportsHiddenFiles = 0x400000000000000LL, + kCFURLVolumeSupportsDecmpFSCompression = 0x800000000000000LL, + kCFURLVolumeHas64BitObjectIDs = 0x1000000000000000LL, + kCFURLVolumePropertyFlagsAll = 0xffffffffffffffffLL +}; + + +/* + _CFURLGetVolumePropertyFlags - Returns a bit array of volume properties. + Only flags whose corresponding bits are set in the "mask" parameter are valid + in the output bit array. Returns true on success, false if an error occurs. + Optional output error: the error is set to a valid CFErrorRef if and only if the function + returns false. A valid output error must be released by the caller. + */ +CF_EXPORT +Boolean _CFURLGetVolumePropertyFlags(CFURLRef url, CFURLVolumePropertyFlags mask, CFURLVolumePropertyFlags *flags, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + + +/* _CFURLCopyResourcePropertyForKeyFromCache works like CFURLCopyResourcePropertyForKey + only it never causes I/O. If the property value requested is cached (or known + to be not available) for the resource, return TRUE and the property value. The + property value returned could be NULL meaning that property is not available + for the resource. If the property value requested is not cached or the resource, + FALSE is returned. + + Only for use by DesktopServices! + */ +CF_EXPORT +Boolean _CFURLCopyResourcePropertyForKeyFromCache(CFURLRef url, CFStringRef key, void *cfTypeRefValue) CF_AVAILABLE(10_8, NA); + +/* _CFURLCopyResourcePropertiesForKeysFromCache works like CFURLCopyResourcePropertiesForKeys + only it never causes I/O. If the property values requested are cached (or known + to be not available) for the resource, return a CFDictionary. Property values + not available for the resource are not included in the CFDictionary. + If the values requested are not cached, return NULL. + + Only for use by DesktopServices! + */ +CF_EXPORT +CFDictionaryRef _CFURLCopyResourcePropertiesForKeysFromCache(CFURLRef url, CFArrayRef keys) CF_AVAILABLE(10_8, NA); + +/* _CFURLCacheResourcePropertyForKey works like CFURLCopyResourcePropertyForKey + only it does not return the property value -- it just ensures the value is cached. + If no errors occur, TRUE is returned. If an error occurs, FALSE is returned + and the optional output error is set to a valid CFErrorRef (which must be + released by the caller. + + Only for use by DesktopServices! + */ +CF_EXPORT +Boolean _CFURLCacheResourcePropertyForKey(CFURLRef url, CFStringRef key, CFErrorRef *error) CF_AVAILABLE(10_8, NA); + +/* _CFURLCacheResourcePropertiesForKeys works like CFURLCopyResourcePropertiesForKeys + only it does not return the property values -- it just ensures the values is cached. + If no errors occur, TRUE is returned. If an error occurs, FALSE is returned + and the optional output error is set to a valid CFErrorRef (which must be + released by the caller. + + Only for use by DesktopServices! + */ +CF_EXPORT +Boolean _CFURLCacheResourcePropertiesForKeys(CFURLRef url, CFArrayRef keys, CFErrorRef *error) CF_AVAILABLE(10_8, NA); + +/* + _CFURLCreateDisplayPathComponentsArray() + + Summary: + _FileURLCreateDisplayPathComponentsArray creates a CFArray of + CFURLs for each component in the path leading up to the target + URL. This routine is suitable for clients who wish to show the + path leading up to a file system item. NOTE: This routine can be + I/O intensive, so use it sparingly, and cache the results if + possible. + + Discussion: + The CFURLs in the result CFArray are ordered from the target URL + to the root of the display path. For example, if the target URL + is file://localhost/System/Library/ the CFURLs in the array will + be ordered: file://localhost/System/Library/, + file://localhost/System/, and then file://localhost/ + + Parameters: + + targetURL: + The target URL. + + error: + A pointer to a CFErrorRef, or NULL. If error is non-NULL and + the function result is NULL, this will be filled in with a + CFErrorRef representing the error that occurred. + + Result: + A CFArray or NULL if an error occurred. + */ +CF_EXPORT +CFArrayRef _CFURLCreateDisplayPathComponentsArray(CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_7, 4_0); + +/* Returns true for URLs that locate file system resources. */ +CF_EXPORT +Boolean _CFURLIsFileURL(CFURLRef url) CF_AVAILABLE(10_6, 4_0); + +/* Deprecated and scheduled for removal in 10.10/8.0 - Use the public API CFURLIsFileReferenceURL() */ +CF_EXPORT +Boolean _CFURLIsFileReferenceURL(CFURLRef url) CF_DEPRECATED(10_6, 10_9, 4_0, 7_0); + +/* For use by Core Services */ +CF_EXPORT +void *__CFURLResourceInfoPtr(CFURLRef url) CF_AVAILABLE(10_6, 4_0); + +CF_EXPORT +void __CFURLSetResourceInfoPtr(CFURLRef url, void *ptr) CF_AVAILABLE(10_6, 4_0); + + +struct FSCatalogInfo; +struct HFSUniStr255; + +/* _CFURLGetCatalogInfo is used by LaunchServices */ +CF_EXPORT +SInt32 _CFURLGetCatalogInfo(CFURLRef url, UInt32 whichInfo, struct FSCatalogInfo *catalogInfo, struct HFSUniStr255 *name) CF_AVAILABLE(10_7, 5_0); + +/* _CFURLReplaceObject SPI */ + +/* options for _CFURLReplaceObject */ +enum { +// _CFURLItemReplacementUsingOriginalMetadataOnly = 1, // not used + _CFURLItemReplacementUsingNewMetadataOnly = 2, +// _CFURLItemReplacementByMergingMetadata = 3, // not used + _CFURLItemReplacementWithoutDeletingBackupItem = 1 << 4 +}; + +/* _CFURLReplaceObject is the underlying implementation for -[NSFileManager replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error:] with one additional argument: newName. The optional newName argument can be used to rename the replacement (for example, when replacing "document.rtf" with "document.rtfd") while still preserving the document's metadata. If newName is used, there must be a file or directory at originalItemURL -- if originalItemURL does not exist and newName is not NULL, an error will be returned. + */ +CF_EXPORT +Boolean _CFURLReplaceObject( CFAllocatorRef allocator, CFURLRef originalItemURL, CFURLRef newItemURL, CFStringRef newName, CFStringRef backupItemName, CFOptionFlags options, CFURLRef *resultingURL, CFErrorRef *error ) CF_AVAILABLE(10_7, 5_0); + +CF_EXPORT +Boolean _CFURLIsProtectedDirectory(CFURLRef directoryURL) CF_AVAILABLE(10_10, NA); + +/* _CFURLAttachSecurityScopeToFileURL attaches a sandbox extension to the file URL object. The URL object will then be security-scoped and will be usable with the NSURL's -startAccessingSecurityScopedResource method and CFURL's CFURLStartAccessingSecurityScopedResource() function. The URL object must be a file URL. If the URL object already has a sandbox extension attached, the new extension replaces the previous sandbox extension. If NULL is passed for the sandboxExtension, the sandbox extension (if any) is removed from the URL object. Callers would be responsible for ensuring the sandbox extension matches the URL's file system path. + */ +CF_EXPORT +void _CFURLAttachSecurityScopeToFileURL(CFURLRef url, CFDataRef sandboxExtension) CF_AVAILABLE(10_10, 8_0); + +/* _CFURLCopySecurityScopeFromFileURL copies the sandbox extension attached to the file URL object. If the URL is not a file URL or doesn't have a sandbox extension, NULL will be returned. + */ +CF_EXPORT +CFDataRef _CFURLCopySecurityScopeFromFileURL(CFURLRef url) CF_AVAILABLE(10_10, 8_0); + +CF_EXPORT +void _CFURLSetPermanentResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue) CF_AVAILABLE(10_10, 8_0); + +CF_EXPORT +CFURLEnumeratorResult _CFURLEnumeratorGetURLsBulk(CFURLEnumeratorRef enumerator, CFIndex maximumURLs, CFIndex *actualURLs, CFURLRef *urls, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); + +// Returns a string describing the bookmark data. For debugging purposes only. +CF_EXPORT +CFStringRef _CFURLBookmarkCopyDescription(CFDataRef bookmarkRef) CF_AVAILABLE(10_10, 8_0); + +// private CFURLBookmarkCreationOptions +enum { + kCFURLBookmarkCreationWithFileProvider CF_ENUM_AVAILABLE(10_10, 8_0) = ( 1UL << 26 ), // private option to create bookmarks with file provider string. The file provider string overrides the rest of the bookmark data at resolution time. + kCFURLBookmarkOperatingInsideScopedBookmarksAgent = (1UL << 27), // private option used internally by ScopedBookmarkAgent to prevent recursion between the agent and the framework code. Available 10_7, NA + kCFURLBookmarkCreationAllowCreationIfResourceDoesNotExistMask = ( 1UL << 28 ), // allow creation of a bookmark to a file: scheme with a CFURLRef of item which may not exist. If the filesystem item does not exist, the created bookmark contains essentially no properties beyond the url string. Available 10_7, 5_0. + kCFURLBookmarkCreationDoNotIncludeSandboxExtensionsMask = ( 1UL << 29 ), // If set, sandbox extensions are not included in created bookmarks. Ordinarily, bookmarks (except those created suitable for putting into a bookmark file) will have a sandbox extension added for the item. Available 10_7, NA. + kCFURLBookmarkCreationSuitableForOdocAppleEvent = ( 1UL << 31 ), // add properties we guarantee will be in an odoc AppleEvent. Available 10_10, NA (but supported back to 10.6). +}; + +// private CFURLBookmarkFileCreationOptions +enum { + // FIXME: These three options (kCFBookmarkFileCreationWithoutOverwritingExistingFile, kCFBookmarkFileCreationWithoutAppendingAliasExtension, and kCFBookmarkFileCreationWithoutCreatingResourceFork) are not implemented and have never been used. + kCFBookmarkFileCreationWithoutOverwritingExistingFile = ( 1UL << 8 ), // if destination file already exists don't overwrite it and return an error + kCFBookmarkFileCreationWithoutAppendingAliasExtension = ( 1UL << 9 ), // don't add / change whatever extension is on the created alias file + kCFBookmarkFileCreationWithoutCreatingResourceFork = ( 1UL << 10 ), // don't create the resource-fork half of the alias file +}; + +// private CFURLBookmarkResolutionOptions +enum { + kCFBookmarkResolutionPerformRelativeResolutionFirstMask CF_ENUM_AVAILABLE(10_8, 6_0) = ( 1UL << 11 ), // perform relative resolution before absolute resolution. If this bit is set, for this to be useful a relative URL must also have been passed in and the bookmark when created must have been created relative to another url. +}; + +typedef CF_ENUM(CFIndex, CFURLBookmarkMatchResult) { + kCFURLBookmarkComparisonUnableToCompare = 0x00000000, /* the two bookmarks could not be compared for some reason */ + kCFURLBookmarkComparisonNoMatch = 0x00001000, /* Bookmarks do not refer to the same item */ + kCFURLBookmarkComparisonUnlikelyToMatch = 0x00002000, /* it is unlikely that the two items refer to the same filesystem item */ + kCFURLBookmarkComparisonLikelyToMatch = 0x00004000, /* it is likely that the two items refer to the same filesystem item ( but, they may not ) */ + kCFURLBookmarkComparisonMatch = 0x00008000, /* the two items refer to the same item, but other information in the bookmarks may not match */ + kCFURLBookmarkComparisonExactMatch = 0x0000f000 /* the two bookmarks are identical */ +}; // Available 10_7, NA. + +/* The relativeToURL and matchingPropertyKeys parameters are not used and are ignored */ +CF_EXPORT +CFURLBookmarkMatchResult _CFURLBookmarkDataCompare(CFDataRef bookmark1Ref, CFDataRef bookmark2Ref, CFURLRef relativeToURL, CFArrayRef* matchingPropertyKeys) CF_AVAILABLE(10_7, NA); + +CF_EXPORT +OSStatus _CFURLBookmarkDataToAliasHandle(CFDataRef bookmarkRef, void* aliasHandleP) CF_AVAILABLE(10_7, NA); + +CF_EXPORT +CFURLRef _CFURLCreateByResolvingAliasFile(CFAllocatorRef allocator, CFURLRef url, CFURLBookmarkResolutionOptions options, CFArrayRef propertiesToInclude, CFErrorRef *error ) CF_AVAILABLE(10_10, 8_0); + +/* + The following are properties that can be asked of bookmark data objects in addition to the resource properties + from CFURL itself. + */ + +extern const CFStringRef kCFURLBookmarkOriginalPathKey CF_AVAILABLE(10_7, 5_0); +extern const CFStringRef kCFURLBookmarkOriginalRelativePathKey CF_AVAILABLE(10_7, 5_0); +extern const CFStringRef kCFURLBookmarkOriginalRelativePathComponentsArrayKey CF_AVAILABLE(10_7, 5_0); +extern const CFStringRef kCFURLBookmarkOriginalVolumeNameKey CF_AVAILABLE(10_7, 5_0); +extern const CFStringRef kCFURLBookmarkOriginalVolumeCreationDateKey CF_AVAILABLE(10_7, 5_0); +extern const CFStringRef kCFURLBookmarkFileProviderStringKey CF_AVAILABLE(10_10, 8_0); + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFURLPRIV__ */ + diff --git a/include/CoreFoundation/CFUUID.h b/include/CoreFoundation/CFUUID.h new file mode 100644 index 0000000..acdde5a --- /dev/null +++ b/include/CoreFoundation/CFUUID.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFUUID.h + Copyright (c) 1999-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFUUID__) +#define __COREFOUNDATION_CFUUID__ 1 + +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef const struct __CFUUID * CFUUIDRef; + +typedef struct { + 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; +} CFUUIDBytes; +/* The CFUUIDBytes struct is a 128-bit struct that contains the +raw UUID. A CFUUIDRef can provide such a struct from the +CFUUIDGetUUIDBytes() function. This struct is suitable for +passing to APIs that expect a raw UUID. +*/ + +CF_EXPORT +CFTypeID CFUUIDGetTypeID(void); + +CF_EXPORT +CFUUIDRef CFUUIDCreate(CFAllocatorRef alloc); + /* Create and return a brand new unique identifier */ + +CF_EXPORT +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); + /* Create and return an identifier with the given contents. This may return an existing instance with its ref count bumped because of uniquing. */ + +CF_EXPORT +CFUUIDRef CFUUIDCreateFromString(CFAllocatorRef alloc, CFStringRef uuidStr); + /* Converts from a string representation to the UUID. This may return an existing instance with its ref count bumped because of uniquing. */ + +CF_EXPORT +CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); + /* Converts from a UUID to its string representation. */ + +CF_EXPORT +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); + /* This returns an immortal CFUUIDRef that should not be released. It can be used in headers to declare UUID constants with #define. */ + +CF_EXPORT +CFUUIDBytes CFUUIDGetUUIDBytes(CFUUIDRef uuid); + +CF_EXPORT +CFUUIDRef CFUUIDCreateFromUUIDBytes(CFAllocatorRef alloc, CFUUIDBytes bytes); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFUUID__ */ + diff --git a/include/CoreFoundation/CFUniChar.h b/include/CoreFoundation/CFUniChar.h new file mode 100644 index 0000000..8eb5440 --- /dev/null +++ b/include/CoreFoundation/CFUniChar.h @@ -0,0 +1,270 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFUniChar.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFUNICHAR__) +#define __COREFOUNDATION_CFUNICHAR__ 1 + + +#include +#include + +CF_EXTERN_C_BEGIN + +#define kCFUniCharBitShiftForByte (3) +#define kCFUniCharBitShiftForMask (7) + +CF_INLINE bool CFUniCharIsSurrogateHighCharacter(UniChar character) { + return ((character >= 0xD800UL) && (character <= 0xDBFFUL) ? true : false); +} + +CF_INLINE bool CFUniCharIsSurrogateLowCharacter(UniChar character) { + return ((character >= 0xDC00UL) && (character <= 0xDFFFUL) ? true : false); +} + +CF_INLINE UTF32Char CFUniCharGetLongCharacterForSurrogatePair(UniChar surrogateHigh, UniChar surrogateLow) { + return ((surrogateHigh - 0xD800UL) << 10) + (surrogateLow - 0xDC00UL) + 0x0010000UL; +} + +// The following values coinside TextEncodingFormat format defines in TextCommon.h +enum { + kCFUniCharUTF16Format = 0, + kCFUniCharUTF8Format = 2, + kCFUniCharUTF32Format = 3 +}; + +CF_INLINE bool CFUniCharIsMemberOfBitmap(UTF16Char theChar, const uint8_t *bitmap) { + return (bitmap && (bitmap[(theChar) >> kCFUniCharBitShiftForByte] & (((uint32_t)1) << (theChar & kCFUniCharBitShiftForMask))) ? true : false); +} + +CF_INLINE void CFUniCharAddCharacterToBitmap(UTF16Char theChar, uint8_t *bitmap) { + bitmap[(theChar) >> kCFUniCharBitShiftForByte] |= (((uint32_t)1) << (theChar & kCFUniCharBitShiftForMask)); +} + +CF_INLINE void CFUniCharRemoveCharacterFromBitmap(UTF16Char theChar, uint8_t *bitmap) { + bitmap[(theChar) >> kCFUniCharBitShiftForByte] &= ~(((uint32_t)1) << (theChar & kCFUniCharBitShiftForMask)); +} + +enum { + kCFUniCharControlCharacterSet = 1, + kCFUniCharWhitespaceCharacterSet, + kCFUniCharWhitespaceAndNewlineCharacterSet, + kCFUniCharDecimalDigitCharacterSet, + kCFUniCharLetterCharacterSet, + kCFUniCharLowercaseLetterCharacterSet, + kCFUniCharUppercaseLetterCharacterSet, + kCFUniCharNonBaseCharacterSet, + kCFUniCharCanonicalDecomposableCharacterSet, + kCFUniCharDecomposableCharacterSet = kCFUniCharCanonicalDecomposableCharacterSet, + kCFUniCharAlphaNumericCharacterSet, + kCFUniCharPunctuationCharacterSet, + kCFUniCharIllegalCharacterSet, + kCFUniCharTitlecaseLetterCharacterSet, + kCFUniCharSymbolAndOperatorCharacterSet, + kCFUniCharNewlineCharacterSet, + + kCFUniCharCompatibilityDecomposableCharacterSet = 100, // internal character sets begins here + kCFUniCharHFSPlusDecomposableCharacterSet, + kCFUniCharStrongRightToLeftCharacterSet, + kCFUniCharHasNonSelfLowercaseCharacterSet, + kCFUniCharHasNonSelfUppercaseCharacterSet, + kCFUniCharHasNonSelfTitlecaseCharacterSet, + kCFUniCharHasNonSelfCaseFoldingCharacterSet, + kCFUniCharHasNonSelfMirrorMappingCharacterSet, + kCFUniCharControlAndFormatterCharacterSet, + kCFUniCharCaseIgnorableCharacterSet, + kCFUniCharGraphemeExtendCharacterSet +}; + +CF_EXPORT bool CFUniCharIsMemberOf(UTF32Char theChar, uint32_t charset); + +// This function returns NULL for kCFUniCharControlCharacterSet, kCFUniCharWhitespaceCharacterSet, kCFUniCharWhitespaceAndNewlineCharacterSet, & kCFUniCharIllegalCharacterSet +CF_EXPORT const uint8_t *CFUniCharGetBitmapPtrForPlane(uint32_t charset, uint32_t plane); + +enum { + kCFUniCharBitmapFilled = (uint8_t)0, + kCFUniCharBitmapEmpty = (uint8_t)0xFF, + kCFUniCharBitmapAll = (uint8_t)1 +}; + +CF_EXPORT uint8_t CFUniCharGetBitmapForPlane(uint32_t charset, uint32_t plane, void *bitmap, bool isInverted); + +CF_EXPORT uint32_t CFUniCharGetNumberOfPlanes(uint32_t charset); + +enum { + kCFUniCharToLowercase = 0, + kCFUniCharToUppercase, + kCFUniCharToTitlecase, + kCFUniCharCaseFold +}; + +enum { + kCFUniCharCaseMapFinalSigma = (1UL << 0), + kCFUniCharCaseMapAfter_i = (1UL << 1), + kCFUniCharCaseMapMoreAbove = (1UL << 2), + kCFUniCharCaseMapDutchDigraph = (1UL << 3), + kCFUniCharCaseMapGreekTonos = (1UL << 4) +}; + +CF_EXPORT CFIndex CFUniCharMapCaseTo(UTF32Char theChar, UTF16Char *convertedChar, CFIndex maxLength, uint32_t ctype, uint32_t flags, const uint8_t *langCode); + +CF_EXPORT uint32_t CFUniCharGetConditionalCaseMappingFlags(UTF32Char theChar, UTF16Char *buffer, CFIndex currentIndex, CFIndex length, uint32_t type, const uint8_t *langCode, uint32_t lastFlags); + +enum { + kCFUniCharBiDiPropertyON = 0, + kCFUniCharBiDiPropertyL, + kCFUniCharBiDiPropertyR, + kCFUniCharBiDiPropertyAN, + kCFUniCharBiDiPropertyEN, + kCFUniCharBiDiPropertyAL, + kCFUniCharBiDiPropertyNSM, + kCFUniCharBiDiPropertyCS, + kCFUniCharBiDiPropertyES, + kCFUniCharBiDiPropertyET, + kCFUniCharBiDiPropertyBN, + kCFUniCharBiDiPropertyS, + kCFUniCharBiDiPropertyWS, + kCFUniCharBiDiPropertyB, + kCFUniCharBiDiPropertyRLO, + kCFUniCharBiDiPropertyRLE, + kCFUniCharBiDiPropertyLRO, + kCFUniCharBiDiPropertyLRE, + kCFUniCharBiDiPropertyPDF +}; + +enum { + kCFUniCharCombiningProperty = 0, + kCFUniCharBidiProperty +}; + +// The second arg 'bitmap' has to be the pointer to a specific plane +CF_INLINE uint8_t CFUniCharGetBidiPropertyForCharacter(UTF16Char character, const uint8_t *bitmap) { + if (bitmap) { + uint8_t value = bitmap[(character >> 8)]; + + if (value > kCFUniCharBiDiPropertyPDF) { + bitmap = bitmap + 256 + ((value - kCFUniCharBiDiPropertyPDF - 1) * 256); + return bitmap[character % 256]; + } else { + return value; + } + } + return kCFUniCharBiDiPropertyL; +} + +CF_INLINE uint8_t CFUniCharGetCombiningPropertyForCharacter(UTF16Char character, const uint8_t *bitmap) { + if (bitmap) { + uint8_t value = bitmap[(character >> 8)]; + + if (value) { + bitmap = bitmap + 256 + ((value - 1) * 256); + return bitmap[character % 256]; + } + } + return 0; +} + +CF_EXPORT const void *CFUniCharGetUnicodePropertyDataForPlane(uint32_t propertyType, uint32_t plane); +CF_EXPORT uint32_t CFUniCharGetNumberOfPlanesForUnicodePropertyData(uint32_t propertyType); +CF_EXPORT uint32_t CFUniCharGetUnicodeProperty(UTF32Char character, uint32_t propertyType); + +CF_EXPORT bool CFUniCharFillDestinationBuffer(const UTF32Char *src, CFIndex srcLength, void **dst, CFIndex dstLength, CFIndex *filledLength, uint32_t dstFormat); + +// UTF32 support + +CF_INLINE bool CFUniCharToUTF32(const UTF16Char *src, CFIndex length, UTF32Char *dst, bool allowLossy, bool isBigEndien) { + const UTF16Char *limit = src + length; + UTF32Char character; + + while (src < limit) { + character = *(src++); + + if (CFUniCharIsSurrogateHighCharacter(character)) { + if ((src < limit) && CFUniCharIsSurrogateLowCharacter(*src)) { + character = CFUniCharGetLongCharacterForSurrogatePair(character, *(src++)); + } else { + if (!allowLossy) return false; + character = 0xFFFD; // replacement character + } + } else if (CFUniCharIsSurrogateLowCharacter(character)) { + if (!allowLossy) return false; + character = 0xFFFD; // replacement character + } + + *(dst++) = (isBigEndien ? CFSwapInt32HostToBig(character) : CFSwapInt32HostToLittle(character)); + } + + return true; +} + +CF_INLINE bool CFUniCharFromUTF32(const UTF32Char *src, CFIndex length, UTF16Char *dst, bool allowLossy, bool isBigEndien) { + const UTF32Char *limit = src + length; + UTF32Char character; + + while (src < limit) { + character = (isBigEndien ? CFSwapInt32BigToHost(*(src++)) : CFSwapInt32LittleToHost(*(src++))); + + if (character < 0x10000) { // BMP + if (allowLossy) { + if (CFUniCharIsSurrogateHighCharacter(character)) { + UTF32Char otherCharacter = 0xFFFD; // replacement character + + if (src < limit) { + otherCharacter = (isBigEndien ? CFSwapInt32BigToHost(*src) : CFSwapInt32LittleToHost(*src)); + + + if ((otherCharacter < 0x10000) && CFUniCharIsSurrogateLowCharacter(otherCharacter)) { + *(dst++) = character; ++src; + } else { + otherCharacter = 0xFFFD; // replacement character + } + } + + character = otherCharacter; + } else if (CFUniCharIsSurrogateLowCharacter(character)) { + character = 0xFFFD; // replacement character + } + } else { + if (CFUniCharIsSurrogateHighCharacter(character) || CFUniCharIsSurrogateLowCharacter(character)) return false; + } + } else if (character < 0x110000) { // non-BMP + character -= 0x10000; + *(dst++) = (UTF16Char)((character >> 10) + 0xD800UL); + character = (UTF16Char)((character & 0x3FF) + 0xDC00UL); + } else { + if (!allowLossy) return false; + character = 0xFFFD; // replacement character + } + + *(dst++) = character; + } + return true; +} + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFUNICHAR__ */ + diff --git a/include/CoreFoundation/CFUniCharPriv.h b/include/CoreFoundation/CFUniCharPriv.h new file mode 100644 index 0000000..eb5a0b9 --- /dev/null +++ b/include/CoreFoundation/CFUniCharPriv.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFUniCharPriv.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFUNICHARPRIV__) +#define __COREFOUNDATION_CFUNICHARPRIV__ 1 + +#include +#include + +#define kCFUniCharRecursiveDecompositionFlag (1UL << 30) +#define kCFUniCharNonBmpFlag (1UL << 31) +#define CFUniCharConvertCountToFlag(count) ((count & 0x1F) << 24) +#define CFUniCharConvertFlagToCount(flag) ((flag >> 24) & 0x1F) + +enum { + kCFUniCharCanonicalDecompMapping = (kCFUniCharCaseFold + 1), + kCFUniCharCanonicalPrecompMapping, + kCFUniCharCompatibilityDecompMapping +}; + +CF_EXPORT const void *CFUniCharGetMappingData(uint32_t type); + +#endif /* ! __COREFOUNDATION_CFUNICHARPRIV__ */ + diff --git a/include/CoreFoundation/CFUnicodeDecomposition.h b/include/CoreFoundation/CFUnicodeDecomposition.h new file mode 100644 index 0000000..5623c86 --- /dev/null +++ b/include/CoreFoundation/CFUnicodeDecomposition.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + * CFUnicodeDecomposition.h + * CoreFoundation + * + * Created by aki on Wed Oct 03 2001. + * Copyright (c) 2001-2014, Apple Inc. All rights reserved. + * + */ + +#if !defined(__COREFOUNDATION_CFUNICODEDECOMPOSITION__) +#define __COREFOUNDATION_CFUNICODEDECOMPOSITION__ 1 + +#include + +CF_EXTERN_C_BEGIN + +CF_INLINE bool CFUniCharIsDecomposableCharacter(UTF32Char character, bool isHFSPlusCanonical) { + if (isHFSPlusCanonical && !isHFSPlusCanonical) return false; // hack to get rid of "unused" warning + if (character < 0x80) return false; + return CFUniCharIsMemberOf(character, kCFUniCharHFSPlusDecomposableCharacterSet); +} + +CF_EXPORT CFIndex CFUniCharDecomposeCharacter(UTF32Char character, UTF32Char *convertedChars, CFIndex maxBufferLength); +CF_EXPORT CFIndex CFUniCharCompatibilityDecompose(UTF32Char *convertedChars, CFIndex length, CFIndex maxBufferLength); + +CF_EXPORT bool CFUniCharDecompose(const UTF16Char *src, CFIndex length, CFIndex *consumedLength, void *dst, CFIndex maxLength, CFIndex *filledLength, bool needToReorder, uint32_t dstFormat, bool isHFSPlus); + +CF_EXPORT void CFUniCharPrioritySort(UTF32Char *characters, CFIndex length); + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFUNICODEDECOMPOSITION__ */ + diff --git a/include/CoreFoundation/CFUnicodePrecomposition.h b/include/CoreFoundation/CFUnicodePrecomposition.h new file mode 100644 index 0000000..821d02c --- /dev/null +++ b/include/CoreFoundation/CFUnicodePrecomposition.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + * CFUnicodePrecomposition.h + * CoreFoundation + * + * Created by aki on Wed Oct 03 2001. + * Copyright (c) 2001-2014, Apple Inc. All rights reserved. + * + */ + +#if !defined(__COREFOUNDATION_CFUNICODEPRECOMPOSITION__) +#define __COREFOUNDATION_CFUNICODEPRECOMPOSITION__ 1 + +#include + +CF_EXTERN_C_BEGIN + +// As you can see, this function cannot precompose Hangul Jamo +CF_EXPORT UTF32Char CFUniCharPrecomposeCharacter(UTF32Char base, UTF32Char combining); + +CF_EXPORT bool CFUniCharPrecompose(const UTF16Char *characters, CFIndex length, CFIndex *consumedLength, UTF16Char *precomposed, CFIndex maxLength, CFIndex *filledLength); + +CF_EXTERN_C_END + +#endif /* ! __COREFOUNDATION_CFUNICODEPRECOMPOSITION__ */ + diff --git a/include/CoreFoundation/CFUserNotification.h b/include/CoreFoundation/CFUserNotification.h new file mode 100644 index 0000000..f87a8e6 --- /dev/null +++ b/include/CoreFoundation/CFUserNotification.h @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFUserNotification.h + Copyright (c) 2000-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFUSERNOTIFICATION__) +#define __COREFOUNDATION_CFUSERNOTIFICATION__ 1 + +#include +#include +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct __CFUserNotification * CFUserNotificationRef; + +/* A CFUserNotification is a notification intended to be presented to a +user at the console (if one is present). This is for the use of processes +that do not otherwise have user interfaces, but may need occasional +interaction with a user. There is a parallel API for this functionality +at the System framework level, described in UNCUserNotification.h. + +The contents of the notification can include a header, a message, textfields, +a popup button, radio buttons or checkboxes, a progress indicator, and up to +three ordinary buttons. All of these items are optional, but a default +button will be supplied even if not specified unless the +kCFUserNotificationNoDefaultButtonFlag is set. + +The contents of the notification are specified in the dictionary used to +create the notification, whose keys should be taken from the list of constants +below, and whose values should be either strings or arrays of strings +(except for kCFUserNotificationProgressIndicatorValueKey, in which case the +value should be a number between 0 and 1, for a "definite" progress indicator, +or a boolean, for an "indefinite" progress indicator). Additionally, URLs can +optionally be supplied for an icon, a sound, and a bundle whose Localizable.strings +files will be used to localize strings. + +Certain request flags are specified when a notification is created. +These specify an alert level for the notification, determine whether +radio buttons or check boxes are to be used, specify which if any of these +are checked by default, specify whether any of the textfields are to +be secure textfields, and determine which popup item should be selected +by default. A timeout is also specified, which determines how long the +notification should be supplied to the user (if zero, it will not timeout). + +A CFUserNotification is dispatched for presentation when it is created. +If any reply is required, it may be awaited in one of two ways: either +synchronously, using CFUserNotificationReceiveResponse, or asynchronously, +using a run loop source. CFUserNotificationReceiveResponse has a timeout +parameter that determines how long it will block (zero meaning indefinitely) +and it may be called as many times as necessary until a response arrives. +If a notification has not yet received a response, it may be updated with +new information, or it may be cancelled. Notifications may not be reused. + +When a response arrives, it carries with it response flags that describe +which button was used to dismiss the notification, which checkboxes or +radio buttons were checked, and what the selection of the popup was. +It also carries a response dictionary, which describes the contents +of the textfields. */ + +typedef void (*CFUserNotificationCallBack)(CFUserNotificationRef userNotification, CFOptionFlags responseFlags); + +CF_EXPORT +CFTypeID CFUserNotificationGetTypeID(void); + +CF_EXPORT +CFUserNotificationRef CFUserNotificationCreate(CFAllocatorRef allocator, CFTimeInterval timeout, CFOptionFlags flags, SInt32 *error, CFDictionaryRef dictionary); + +CF_EXPORT +SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags *responseFlags); + +CF_EXPORT +CFStringRef CFUserNotificationGetResponseValue(CFUserNotificationRef userNotification, CFStringRef key, CFIndex idx); + +CF_EXPORT +CFDictionaryRef CFUserNotificationGetResponseDictionary(CFUserNotificationRef userNotification); + +CF_EXPORT +SInt32 CFUserNotificationUpdate(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags flags, CFDictionaryRef dictionary); + +CF_EXPORT +SInt32 CFUserNotificationCancel(CFUserNotificationRef userNotification); + +CF_EXPORT +CFRunLoopSourceRef CFUserNotificationCreateRunLoopSource(CFAllocatorRef allocator, CFUserNotificationRef userNotification, CFUserNotificationCallBack callout, CFIndex order); + +/* Convenience functions for handling the simplest and most common cases: +a one-way notification, and a notification with up to three buttons. */ + +CF_EXPORT +SInt32 CFUserNotificationDisplayNotice(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle); + +CF_EXPORT +SInt32 CFUserNotificationDisplayAlert(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle, CFStringRef alternateButtonTitle, CFStringRef otherButtonTitle, CFOptionFlags *responseFlags); + + +/* Flags */ + +enum { + kCFUserNotificationStopAlertLevel = 0, + kCFUserNotificationNoteAlertLevel = 1, + kCFUserNotificationCautionAlertLevel = 2, + kCFUserNotificationPlainAlertLevel = 3 +}; + +enum { + kCFUserNotificationDefaultResponse = 0, + kCFUserNotificationAlternateResponse = 1, + kCFUserNotificationOtherResponse = 2, + kCFUserNotificationCancelResponse = 3 +}; + +enum { + kCFUserNotificationNoDefaultButtonFlag = (1UL << 5), + kCFUserNotificationUseRadioButtonsFlag = (1UL << 6) +}; + +CF_INLINE CFOptionFlags CFUserNotificationCheckBoxChecked(CFIndex i) {return ((CFOptionFlags)(1UL << (8 + i)));} +CF_INLINE CFOptionFlags CFUserNotificationSecureTextField(CFIndex i) {return ((CFOptionFlags)(1UL << (16 + i)));} +CF_INLINE CFOptionFlags CFUserNotificationPopUpSelection(CFIndex n) {return ((CFOptionFlags)(n << 24));} + + +/* Keys */ + +CF_EXPORT +const CFStringRef kCFUserNotificationIconURLKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationSoundURLKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationLocalizationURLKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationAlertHeaderKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationAlertMessageKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationDefaultButtonTitleKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationAlternateButtonTitleKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationOtherButtonTitleKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationProgressIndicatorValueKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationPopUpTitlesKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationTextFieldTitlesKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationCheckBoxTitlesKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationTextFieldValuesKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationPopUpSelectionKey CF_AVAILABLE(10_3, NA); + +#if (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +CF_EXPORT +const CFStringRef kCFUserNotificationAlertTopMostKey; + +CF_EXPORT +const CFStringRef kCFUserNotificationKeyboardTypesKey; +#endif + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFUSERNOTIFICATION__ */ + diff --git a/include/CoreFoundation/CFUtilities.h b/include/CoreFoundation/CFUtilities.h new file mode 100644 index 0000000..a49b595 --- /dev/null +++ b/include/CoreFoundation/CFUtilities.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFUtilities.h + Copyright (c) 2005-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFUTILITIES__) +#define __COREFOUNDATION_CFUTILITIES__ 1 + +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +CF_EXPORT +CFURLRef CFCopyHomeDirectoryURL(void) CF_AVAILABLE_IOS(5_0); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFUTILITIES__ */ + diff --git a/include/CoreFoundation/CFXMLInputStream.h b/include/CoreFoundation/CFXMLInputStream.h new file mode 100644 index 0000000..a876b07 --- /dev/null +++ b/include/CoreFoundation/CFXMLInputStream.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFXMLInputStream.h + Copyright (c) 2000-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_CFXMLINPUTSTREAM__) +#define __COREFOUNDATION_CFXMLINPUTSTREAM__ 1 + +#include +#include "CFInternal.h" +#include +#include +#include + +struct __CFXMLNode { + // 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 + CFRuntimeBase _cfBase; + CFIndex version; + CFXMLNodeTypeCode dataTypeID; + CFStringRef dataString; + void *additionalData; +}; + +struct __CFXMLInputStream { + CFDataRef data; // The XML data + CFURLRef url; // the source URL for the data + CFStringEncoding encoding; // the data's encoding + const UInt8 *currentByte; // pointer into data at the first byte not yet translated to a character + + UniChar *charBuffer; // the buffer of characters translated from data + UniChar *currentChar; // pointer into charBuffer at the current stream location. MUST be NULL if there are no more characters in charBuffer to consume. + UniChar *mark; // The point at which the mark was dropped. NULL if the mark is currently unset. + UniChar *parserMark; // mark available only for the parser's use + CFIndex bufferLength; // The number of meaningful characters in charBuffer + CFIndex bufferCapacity; // The current maximum capacity of charBuffer in UniChars + + CFIndex charIndex, lineNum; // location in the file + UInt32 flags; // See #defines below for bit flag meanings + CFMutableSetRef nameSet; // set of all names we've encountered; used for uniquing + CFMutableStringRef tempString; + + 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 +}; + +// whether the stream has been opened for reading +#define STREAM_OPEN 0x1 +// whether the encoding matches ASCII over 0x0-0x7F +#define ENCODING_MATCHES_ASCII 0x2 +// whether the encoding is Unicode with the "natural" byte ordering +#define ENCODING_IS_UNICODE_NATURAL 0x4 +// whether the encoding is Unicode with the bytes swapped +#define ENCODING_IS_UNICODE_SWAPPED 0x8 +// whether the stream has encountered an error in encodings. +#define ENCODING_COMPOSITION_ERROR 0x10 + +typedef struct __CFXMLInputStream _CFXMLInputStream; + +void _initializeInputStream(_CFXMLInputStream *stream, CFAllocatorRef alloc, CFURLRef dataSource, CFDataRef xmlData); +Boolean _openInputStream(_CFXMLInputStream *stream); // None of the subsequent calls will work until the input stream has been opened +void _freeInputStream(_CFXMLInputStream *stream); + +CFStringEncoding _inputStreamGetEncoding(_CFXMLInputStream *stream); +CFIndex _inputStreamCurrentLocation(_CFXMLInputStream *stream); +CFIndex _inputStreamCurrentLine(_CFXMLInputStream *stream); +Boolean _inputStreamAtEOF(_CFXMLInputStream *stream); +Boolean _inputStreamComposingErrorOccurred(_CFXMLInputStream *stream); + +Boolean _inputStreamPeekCharacter(_CFXMLInputStream *stream, UniChar *ch); +Boolean _inputStreamGetCharacter(_CFXMLInputStream *stream, UniChar *ch); +Boolean _inputStreamReturnCharacter(_CFXMLInputStream *stream, UniChar ch); +void _inputStreamSetMark(_CFXMLInputStream *stream); +void _inputStreamClearMark(_CFXMLInputStream *stream); +void _inputStreamGetCharactersFromMark(_CFXMLInputStream *stream, CFMutableStringRef string); +void _inputStreamBackUpToMark(_CFXMLInputStream *stream); +void _inputStringInitialize(_CFXMLInputStream *stream, UniChar *characters, CFIndex length); +CFIndex _inputStreamSkipWhitespace(_CFXMLInputStream *stream, CFMutableStringRef str); +Boolean _inputStreamScanToCharacters(_CFXMLInputStream *stream, const UniChar *scanChars, CFIndex numChars, CFMutableStringRef str); +Boolean _inputStreamMatchString(_CFXMLInputStream *stream, const UniChar *stringToMatch, CFIndex length); +Boolean _inputStreamScanQuotedString(_CFXMLInputStream *stream, CFMutableStringRef str); +Boolean _inputStreamScanXMLName(_CFXMLInputStream *stream, Boolean isNMToken, CFStringRef *str); + +/* Returns the character index within the current line of the current parse location */ +/* To add someday -- CF_EXPORT +CFIndex CFXMLParserGetOffsetInCurrentLine(CFXMLParserRef parser); */ + +#endif /* ! __COREFOUNDATION_CFXMLINPUTSTREAM__ */ + diff --git a/include/CoreFoundation/CFXMLNode.h b/include/CoreFoundation/CFXMLNode.h new file mode 100644 index 0000000..7750168 --- /dev/null +++ b/include/CoreFoundation/CFXMLNode.h @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFXMLNode.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +/* CFXMLParser (and thus CFXMLNode) are deprecated as of Mac OS X 10.8 and iOS 6.0. The suggested replacements are the Foundation classes NSXMLParser and NSXMLDocument, or the libxml2 library. */ + +#if !defined(__COREFOUNDATION_CFXMLNODE__) +#define __COREFOUNDATION_CFXMLNODE__ 1 + +#include +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +enum { + kCFXMLNodeCurrentVersion = 1 +}; + +typedef const struct __CFXMLNode * CFXMLNodeRef; +typedef CFTreeRef CFXMLTreeRef; + +/* An CFXMLNode describes an individual XML construct - like a tag, or a comment, or a string + of character data. Each CFXMLNode contains 3 main pieces of information - the node's type, + the data string, and a pointer to an additional data structure. The node's type ID is an enum + value of type CFXMLNodeTypeID. The data string is always a CFStringRef; the meaning of the + string is dependent on the node's type ID. The format of the additional data is also dependent + on the node's type; in general, there is a custom structure for each type that requires + additional data. See below for the mapping from type ID to meaning of the data string and + structure of the additional data. Note that these structures are versioned, and may change + as the parser changes. The current version can always be identified by kCFXMLNodeCurrentVersion; + earlier versions can be identified and used by passing earlier values for the version number + (although the older structures would have been removed from the header). + + An CFXMLTree is simply a CFTree whose context data is known to be an CFXMLNodeRef. As + such, an CFXMLTree can be used to represent an entire XML document; the CFTree + provides the tree structure of the document, while the CFXMLNodes identify and describe + the nodes of the tree. An XML document can be parsed to a CFXMLTree, and a CFXMLTree + can generate the data for the equivalent XML document - see CFXMLParser.h for more + information on parsing XML. + */ + +/* Type codes for the different possible XML nodes; this list may grow.*/ +typedef CF_ENUM(CFIndex, CFXMLNodeTypeCode) { + kCFXMLNodeTypeDocument = 1, + kCFXMLNodeTypeElement = 2, + kCFXMLNodeTypeAttribute = 3, + kCFXMLNodeTypeProcessingInstruction = 4, + kCFXMLNodeTypeComment = 5, + kCFXMLNodeTypeText = 6, + kCFXMLNodeTypeCDATASection = 7, + kCFXMLNodeTypeDocumentFragment = 8, + kCFXMLNodeTypeEntity = 9, + kCFXMLNodeTypeEntityReference = 10, + kCFXMLNodeTypeDocumentType = 11, + kCFXMLNodeTypeWhitespace = 12, + kCFXMLNodeTypeNotation = 13, + kCFXMLNodeTypeElementTypeDeclaration = 14, + kCFXMLNodeTypeAttributeListDeclaration = 15 +}; + +typedef struct { + CFDictionaryRef attributes; + CFArrayRef attributeOrder; + Boolean isEmpty; + char _reserved[3]; +} CFXMLElementInfo; + +typedef struct { + CFStringRef dataString; +} CFXMLProcessingInstructionInfo; + +typedef struct { + CFURLRef sourceURL; + CFStringEncoding encoding; +} CFXMLDocumentInfo; + +typedef struct { + CFURLRef systemID; + CFStringRef publicID; +} CFXMLExternalID; + +typedef struct { + CFXMLExternalID externalID; +} CFXMLDocumentTypeInfo; + +typedef struct { + CFXMLExternalID externalID; +} CFXMLNotationInfo; + +typedef struct { + /* This is expected to change in future versions */ + CFStringRef contentDescription; +} CFXMLElementTypeDeclarationInfo; + +typedef struct { + /* This is expected to change in future versions */ + CFStringRef attributeName; + CFStringRef typeString; + CFStringRef defaultString; +} CFXMLAttributeDeclarationInfo; + +typedef struct { + CFIndex numberOfAttributes; + CFXMLAttributeDeclarationInfo *attributes; +} CFXMLAttributeListDeclarationInfo; + +typedef CF_ENUM(CFIndex, CFXMLEntityTypeCode) { + kCFXMLEntityTypeParameter, /* Implies parsed, internal */ + kCFXMLEntityTypeParsedInternal, + kCFXMLEntityTypeParsedExternal, + kCFXMLEntityTypeUnparsed, + kCFXMLEntityTypeCharacter +}; + +typedef struct { + CFXMLEntityTypeCode entityType; + CFStringRef replacementText; /* NULL if entityType is external or unparsed */ + CFXMLExternalID entityID; /* entityID.systemID will be NULL if entityType is internal */ + CFStringRef notationName; /* NULL if entityType is parsed */ +} CFXMLEntityInfo; + +typedef struct { + CFXMLEntityTypeCode entityType; +} CFXMLEntityReferenceInfo; + +/* + dataTypeCode meaning of dataString format of infoPtr + =========== ===================== ================= + kCFXMLNodeTypeDocument CFXMLDocumentInfo * + kCFXMLNodeTypeElement tag name CFXMLElementInfo * + kCFXMLNodeTypeAttribute + kCFXMLNodeTypeProcessingInstruction name of the target CFXMLProcessingInstructionInfo * + kCFXMLNodeTypeComment text of the comment NULL + kCFXMLNodeTypeText the text's contents NULL + kCFXMLNodeTypeCDATASection text of the CDATA NULL + kCFXMLNodeTypeDocumentFragment + kCFXMLNodeTypeEntity name of the entity CFXMLEntityInfo * + kCFXMLNodeTypeEntityReference name of the referenced entity CFXMLEntityReferenceInfo * + kCFXMLNodeTypeDocumentType name given as top-level element CFXMLDocumentTypeInfo * + kCFXMLNodeTypeWhitespace text of the whitespace NULL + kCFXMLNodeTypeNotation notation name CFXMLNotationInfo * + kCFXMLNodeTypeElementTypeDeclaration tag name CFXMLElementTypeDeclarationInfo * + kCFXMLNodeTypeAttributeListDeclaration tag name CFXMLAttributeListDeclarationInfo * +*/ + +CF_EXPORT +CFTypeID CFXMLNodeGetTypeID(void) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Creates a new node based on xmlType, dataString, and additionalInfoPtr. version (together with xmlType) determines the expected structure of additionalInfoPtr */ +CF_EXPORT +CFXMLNodeRef CFXMLNodeCreate(CFAllocatorRef alloc, CFXMLNodeTypeCode xmlType, CFStringRef dataString, const void *additionalInfoPtr, CFIndex version) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Creates a copy of origNode (which may not be NULL). */ +CF_EXPORT +CFXMLNodeRef CFXMLNodeCreateCopy(CFAllocatorRef alloc, CFXMLNodeRef origNode) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXPORT +CFXMLNodeTypeCode CFXMLNodeGetTypeCode(CFXMLNodeRef node) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXPORT +CFStringRef CFXMLNodeGetString(CFXMLNodeRef node) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXPORT +const void *CFXMLNodeGetInfoPtr(CFXMLNodeRef node) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXPORT +CFIndex CFXMLNodeGetVersion(CFXMLNodeRef node) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* CFXMLTreeRef */ + +/* Creates a childless, parentless tree from node */ +CF_EXPORT +CFXMLTreeRef CFXMLTreeCreateWithNode(CFAllocatorRef allocator, CFXMLNodeRef node) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Extracts and returns the node stored in xmlTree */ +CF_EXPORT +CFXMLNodeRef CFXMLTreeGetNode(CFXMLTreeRef xmlTree) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFXMLNODE__ */ + diff --git a/include/CoreFoundation/CFXMLParser.h b/include/CoreFoundation/CFXMLParser.h new file mode 100644 index 0000000..325e21d --- /dev/null +++ b/include/CoreFoundation/CFXMLParser.h @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CFXMLParser.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +/* CFXMLParser is deprecated as of Mac OS X 10.8. The suggested replacements are the Foundation classes NSXMLParser and NSXMLDocument, or the libxml2 library. */ + +#if !defined(__COREFOUNDATION_CFXMLPARSER__) +#define __COREFOUNDATION_CFXMLPARSER__ 1 + +#include +#include +#include +#include +#include +#include +#include + +CF_IMPLICIT_BRIDGING_ENABLED +CF_EXTERN_C_BEGIN + +typedef struct __CFXMLParser * CFXMLParserRef; + +/* These are the various options you can configure the parser with. These are + chosen such that an option flag of 0 (kCFXMLParserNoOptions) leaves the XML + as "intact" as possible (reports all structures; performs no replacements). + Hence, to make the parser do the most work, returning only the pure element + tree, set the option flag to kCFXMLParserAllOptions. + +kCFXMLParserValidateDocument - + validate the document against its grammar from the DTD, reporting any errors. + Currently not supported. + +kCFXMLParserSkipMetaData - + silently skip over metadata constructs (the DTD and comments) + +kCFXMLParserReplacePhysicalEntities - + replace declared entities like <. Note that other than the 5 predefined + entities (lt, gt, quot, amp, apos), these must be defined in the DTD. + Currently not supported. + +kCFXMLParserSkipWhitespace - + skip over all whitespace that does not abut non-whitespace character data. + In other words, given blah , the whitespace between + foo's open tag and bar's open tag would be suppressed, but the whitespace + around blah would be preserved. + +kCFXMLParserAddImpliedAttributes - + where the DTD specifies implied attribute-value pairs for a particular element, + add those pairs to any occurances of the element in the element tree. + Currently not supported. +*/ + +typedef CF_OPTIONS(CFOptionFlags, CFXMLParserOptions) { + kCFXMLParserValidateDocument = (1UL << 0), + kCFXMLParserSkipMetaData = (1UL << 1), + kCFXMLParserReplacePhysicalEntities = (1UL << 2), + kCFXMLParserSkipWhitespace = (1UL << 3), + kCFXMLParserResolveExternalEntities = (1UL << 4), + kCFXMLParserAddImpliedAttributes = (1UL << 5), + kCFXMLParserAllOptions = 0x00FFFFFF, + kCFXMLParserNoOptions = 0 +}; + +/* This list is expected to grow */ +typedef CF_OPTIONS(CFIndex, CFXMLParserStatusCode) { + kCFXMLStatusParseNotBegun = -2, + kCFXMLStatusParseInProgress = -1, + kCFXMLStatusParseSuccessful = 0, + kCFXMLErrorUnexpectedEOF = 1, + kCFXMLErrorUnknownEncoding, + kCFXMLErrorEncodingConversionFailure, + kCFXMLErrorMalformedProcessingInstruction, + kCFXMLErrorMalformedDTD, + kCFXMLErrorMalformedName, + kCFXMLErrorMalformedCDSect, + kCFXMLErrorMalformedCloseTag, + kCFXMLErrorMalformedStartTag, + kCFXMLErrorMalformedDocument, + kCFXMLErrorElementlessDocument, + kCFXMLErrorMalformedComment, + kCFXMLErrorMalformedCharacterReference, + kCFXMLErrorMalformedParsedCharacterData, + kCFXMLErrorNoData +}; + + +/* These functions are called as a parse progresses. + +createXMLStructure - + called as new XML structures are encountered by the parser. May return NULL to indicate + that the given structure should be skipped; if NULL is returned for a given structure, + only minimal parsing is done for that structure (enough to correctly determine its end, + and to extract any data necessary for the remainder of the parse, such as Entity definitions). + createXMLStructure (or indeed, any of the tree-creation callbacks) will not be called for any + children of the skipped structure. The only exception is that the top-most element will always + be reported even if NULL was returned for the document as a whole. NOTE: for performance reasons, + the node passed to createXMLStructure cannot be safely retained by the client; the node as + a whole must be copied (via CFXMLNodeCreateCopy), or its contents must be extracted and copied. + +addChild - + called as children are parsed and are ready to be added to the tree. If createXMLStructure + returns NULL for a given structure, that structure is omitted entirely, and addChild will + NOT be called for either a NULL child or parent. + +endXMLStructure - + called once a structure (and all its children) are completely parsed. As elements are encountered, + createXMLStructure is called for them first, then addChild to add the new structure to its parent, + then addChild (potentially several times) to add the new structure's children to it, then finally + endXMLStructure to show that the structure has been fully parsed. + +createXMLStructure, addChild, and endXMLStructure are all REQUIRED TO BE NON-NULL. + +resolveExternalEntity - + called when external entities are referenced (NOT when they are simply defined). If the function + pointer is NULL, the parser uses its internal routines to try and resolve the entity. If the + function pointer is set, and the function returns NULL, a place holder for the external entity + is inserted into the tree. In this manner, the parser's client can prevent any external network + or file accesses. + +handleError - called as errors/warnings are encountered in the data stream. At some point, we will + have an enum of the expected errors, some of which will be fatal, others of which will not. If + the function pointer is NULL, the parser will silently attempt to recover. The + handleError function may always return false to force the parser to stop; if handleError returns + true, the parser will attempt to recover (fatal errors will still cause the parse to abort + immediately). +*/ + +typedef void * (*CFXMLParserCreateXMLStructureCallBack)(CFXMLParserRef parser, CFXMLNodeRef nodeDesc, void *info); +typedef void (*CFXMLParserAddChildCallBack)(CFXMLParserRef parser, void *parent, void *child, void *info); +typedef void (*CFXMLParserEndXMLStructureCallBack)(CFXMLParserRef parser, void *xmlType, void *info); +typedef CFDataRef (*CFXMLParserResolveExternalEntityCallBack)(CFXMLParserRef parser, CFXMLExternalID *extID, void *info); +typedef Boolean (*CFXMLParserHandleErrorCallBack)(CFXMLParserRef parser, CFXMLParserStatusCode error, void *info); +typedef struct { + CFIndex version; + CFXMLParserCreateXMLStructureCallBack createXMLStructure; + CFXMLParserAddChildCallBack addChild; + CFXMLParserEndXMLStructureCallBack endXMLStructure; + CFXMLParserResolveExternalEntityCallBack resolveExternalEntity; + CFXMLParserHandleErrorCallBack handleError; +} CFXMLParserCallBacks; + +typedef const void * (*CFXMLParserRetainCallBack)(const void *info); +typedef void (*CFXMLParserReleaseCallBack)(const void *info); +typedef CFStringRef (*CFXMLParserCopyDescriptionCallBack)(const void *info); +typedef struct { + CFIndex version; + void * info; + CFXMLParserRetainCallBack retain; + CFXMLParserReleaseCallBack release; + CFXMLParserCopyDescriptionCallBack copyDescription; +} CFXMLParserContext; + +CF_EXPORT +CFTypeID CFXMLParserGetTypeID(void) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Creates a parser which will parse the given data with the given options. xmlData may not be NULL. + dataSource should be the URL from which the data came, and may be NULL; it is used to resolve any + relative references found in xmlData. versionOfNodes determines which version CFXMLNodes are produced + by the parser; see CFXMLNode.h for more details. callBacks are the callbacks called by the parser as + the parse progresses; callBacks, callBacks->createXMLStructure, callBacks->addChild, and + callBacks->endXMLStructure must all be non-NULL. context determines what if any info pointer is + passed to the callbacks as the parse progresses; context may be NULL. */ +CF_EXPORT +CFXMLParserRef CFXMLParserCreate(CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes, CFXMLParserCallBacks *callBacks, CFXMLParserContext *context) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Arguments as above, except that the data to be parsed is loaded directly + from dataSource. dataSource may not be NULL. */ +CF_EXPORT +CFXMLParserRef CFXMLParserCreateWithDataFromURL(CFAllocatorRef allocator, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes, CFXMLParserCallBacks *callBacks, CFXMLParserContext *context) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXPORT +void CFXMLParserGetContext(CFXMLParserRef parser, CFXMLParserContext *context) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXPORT +void CFXMLParserGetCallBacks(CFXMLParserRef parser, CFXMLParserCallBacks *callBacks) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXPORT +CFURLRef CFXMLParserGetSourceURL(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Returns the character index of the current parse location */ +CF_EXPORT +CFIndex CFXMLParserGetLocation(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Returns the line number of the current parse location */ +CF_EXPORT +CFIndex CFXMLParserGetLineNumber(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Returns the top-most object returned by the createXMLStructure callback */ +CF_EXPORT +void *CFXMLParserGetDocument(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Get the status code or a user-readable description of the last error that occurred in a parse. + If no error has occurred, a null description string is returned. See the enum above for + possible status returns */ +CF_EXPORT +CFXMLParserStatusCode CFXMLParserGetStatusCode(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +CF_EXPORT +CFStringRef CFXMLParserCopyErrorDescription(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Cause any in-progress parse to abort with the given error code and description. errorCode + must be positive, and errorDescription may not be NULL. Cannot be called asynchronously + (i.e. must be called from within a parser callback) */ +CF_EXPORT +void CFXMLParserAbort(CFXMLParserRef parser, CFXMLParserStatusCode errorCode, CFStringRef errorDescription) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Starts a parse of the data the parser was created with; returns success or failure. + Upon success, use CFXMLParserGetDocument() to get the product of the parse. Upon + failure, use CFXMLParserGetErrorCode() or CFXMLParserCopyErrorDescription() to get + information about the error. It is an error to call CFXMLParserParse() while a + parse is already underway. */ +CF_EXPORT +Boolean CFXMLParserParse(CFXMLParserRef parser) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* These functions provide a higher-level interface. The XML data is parsed to a + special CFTree (an CFXMLTree) with known contexts and callbacks. See CFXMLNode.h + for full details on using an CFXMLTree and the CFXMLNodes contained therein. +*/ +/* Parse to an CFXMLTreeRef. parseOptions are as above. versionOfNodes determines + what version CFXMLNodes are used to populate the tree. */ +CF_EXPORT +CFXMLTreeRef CFXMLTreeCreateFromData(CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* As above, with the additional by-reference pass of a CFDictionaryRef containing + various error information (see below). The caller is responsible for releasing the + returned dictionary. If the error dictionary is not desired, pass NULL. */ +CF_EXPORT +CFXMLTreeRef CFXMLTreeCreateFromDataWithError(CFAllocatorRef allocator, CFDataRef xmlData, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes, CFDictionaryRef *errorDict) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Loads the data to be parsed directly from dataSource. Arguments as above. */ +CF_EXPORT +CFXMLTreeRef CFXMLTreeCreateWithDataFromURL(CFAllocatorRef allocator, CFURLRef dataSource, CFOptionFlags parseOptions, CFIndex versionOfNodes) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Generate the XMLData (ready to be written to whatever permanent storage is to be + used) from an CFXMLTree. Will NOT regenerate entity references (except those + required for syntactic correctness) if they were replaced at the parse time; + clients that wish this should walk the tree and re-insert any entity references + that should appear in the final output file. */ +CF_EXPORT +CFDataRef CFXMLTreeCreateXMLData(CFAllocatorRef allocator, CFXMLTreeRef xmlTree) CF_DEPRECATED(10_0, 10_8, 2_0, 6_0); + +/* Escaping and unescaping XML entities in CFStrings. The standard XML entities + are always replaced. */ +/* Creates a CFString by replacing entities that appear in the entities dictionary. + Dictionary keys are the entities themselves, and the values should be CFStrings + containing the expansion. Pass NULL for entitiesDictionary to indicate no entities + other than the standard five. */ +CF_EXPORT +CFStringRef CFXMLCreateStringByEscapingEntities(CFAllocatorRef allocator, CFStringRef string, CFDictionaryRef entitiesDictionary); + +CF_EXPORT +CFStringRef CFXMLCreateStringByUnescapingEntities(CFAllocatorRef allocator, CFStringRef string, CFDictionaryRef entitiesDictionary); + +/* CFXMLTreeCreateFromDataWithError error dictionary key constants. */ +CF_EXPORT const CFStringRef kCFXMLTreeErrorDescription; + /* value is a CFString containing the readable error string. */ + +CF_EXPORT const CFStringRef kCFXMLTreeErrorLineNumber; + /* value is a CFNumber containing the line on which the error appears. */ + +CF_EXPORT const CFStringRef kCFXMLTreeErrorLocation; + /* value is a CFNumber containing the byte location at which the error occurred. */ + +CF_EXPORT const CFStringRef kCFXMLTreeErrorStatusCode; + /* value is a CFNumber containing the error status code. */ + +CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED + +#endif /* ! __COREFOUNDATION_CFXMLPARSER__ */ + diff --git a/include/CoreFoundation/CFXPCBridge.h b/include/CoreFoundation/CFXPCBridge.h new file mode 100644 index 0000000..272abf8 --- /dev/null +++ b/include/CoreFoundation/CFXPCBridge.h @@ -0,0 +1,37 @@ +/* CFXPCBridge.h + + Copyright (C) 2016 Lubos Dolezel + + This file is part of the GNUstep CoreBase Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __CFCOREFOUNDATION_CFXPC_H__ +#define __CFCOREFOUNDATION_CFXPC_H__ +#include +#include + +CF_EXTERN_C_BEGIN + +extern CFTypeRef _CFXPCCreateCFObjectFromXPCObject(xpc_object_t xpcattrs); + +extern xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef attrs); + +CF_EXTERN_C_END + +#endif diff --git a/include/CoreFoundation/CoreFoundation.h b/include/CoreFoundation/CoreFoundation.h new file mode 100644 index 0000000..e4dd439 --- /dev/null +++ b/include/CoreFoundation/CoreFoundation.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* CoreFoundation.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !defined(__COREFOUNDATION_COREFOUNDATION__) +#define __COREFOUNDATION_COREFOUNDATION__ 1 +#define __COREFOUNDATION__ 1 + +#if !defined(CF_EXCLUDE_CSTD_HEADERS) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(__STDC_VERSION__) && (199901L <= __STDC_VERSION__) + +#include +#include +#include + +#endif + +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || TARGET_OS_WIN32 +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#endif + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) +#endif + +#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) +#include +#include +#include +#endif + + +#endif /* ! __COREFOUNDATION_COREFOUNDATION__ */ + diff --git a/include/CoreFoundation/ForFoundationOnly.h b/include/CoreFoundation/ForFoundationOnly.h new file mode 100644 index 0000000..7495625 --- /dev/null +++ b/include/CoreFoundation/ForFoundationOnly.h @@ -0,0 +1,639 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* ForFoundationOnly.h + Copyright (c) 1998-2014, Apple Inc. All rights reserved. +*/ + +#if !CF_BUILDING_CF && !NSBUILDINGFOUNDATION + #error The header file ForFoundationOnly.h is for the exclusive use of the + #error CoreFoundation and Foundation projects. No other project should include it. +#endif + +#if !defined(__COREFOUNDATION_FORFOUNDATIONONLY__) +#define __COREFOUNDATION_FORFOUNDATIONONLY__ 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// NOTE: miscellaneous declarations are at the end + +// ---- CFRuntime material ---------------------------------------- + +CF_EXTERN_C_BEGIN + +#if DEPLOYMENT_TARGET_LINUX +#include +#elif DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI +#include +#endif + +CF_EXTERN_C_END + +// ---- CFBundle material ---------------------------------------- + +#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI || DEPLOYMENT_TARGET_WINDOWS +#include + +CF_EXTERN_C_BEGIN + +CF_EXPORT const CFStringRef _kCFBundleExecutablePathKey; +CF_EXPORT const CFStringRef _kCFBundleInfoPlistURLKey; +CF_EXPORT const CFStringRef _kCFBundleRawInfoPlistURLKey; +CF_EXPORT const CFStringRef _kCFBundleNumericVersionKey; +CF_EXPORT const CFStringRef _kCFBundleResourcesFileMappedKey; +CF_EXPORT const CFStringRef _kCFBundleAllowMixedLocalizationsKey; +CF_EXPORT const CFStringRef _kCFBundleInitialPathKey; +CF_EXPORT const CFStringRef _kCFBundleResolvedPathKey; +CF_EXPORT const CFStringRef _kCFBundlePrincipalClassKey; + +#if __BLOCKS__ +CF_EXPORT CFTypeRef _CFBundleCopyFindResources(CFBundleRef bundle, CFURLRef bundleURL, CFArrayRef _unused_pass_null_, CFStringRef resourceName, CFStringRef resourceType, CFStringRef subPath, CFStringRef lproj, Boolean returnArray, Boolean localized, Boolean (^predicate)(CFStringRef filename, Boolean *stop)); +#endif + +CF_EXPORT Boolean _CFBundleLoadExecutableAndReturnError(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error); +CF_EXPORT CFErrorRef _CFBundleCreateError(CFAllocatorRef allocator, CFBundleRef bundle, CFIndex code); + +CF_EXTERN_C_END + +#endif + +// ---- CFPreferences material ---------------------------------------- + +#define DEBUG_PREFERENCES_MEMORY 0 + +#if DEBUG_PREFERENCES_MEMORY +#include "../Tests/CFCountingAllocator.h" +#endif + +CF_EXTERN_C_BEGIN + +extern void _CFPreferencesPurgeDomainCache(void); + +typedef struct { + void * (*createDomain)(CFAllocatorRef allocator, CFTypeRef context); + void (*freeDomain)(CFAllocatorRef allocator, CFTypeRef context, void *domain); + CFTypeRef (*fetchValue)(CFTypeRef context, void *domain, CFStringRef key); // Caller releases + void (*writeValue)(CFTypeRef context, void *domain, CFStringRef key, CFTypeRef value); + Boolean (*synchronize)(CFTypeRef context, void *domain); + void (*getKeysAndValues)(CFAllocatorRef alloc, CFTypeRef context, void *domain, void **buf[], CFIndex *numKeyValuePairs); + CFDictionaryRef (*copyDomainDictionary)(CFTypeRef context, void *domain); + /* HACK - see comment on _CFPreferencesDomainSetIsWorldReadable(), below */ + void (*setIsWorldReadable)(CFTypeRef context, void *domain, Boolean isWorldReadable); +} _CFPreferencesDomainCallBacks; + +CF_EXPORT CFAllocatorRef __CFPreferencesAllocator(void); +CF_EXPORT const _CFPreferencesDomainCallBacks __kCFVolatileDomainCallBacks; +CF_EXPORT const _CFPreferencesDomainCallBacks __kCFXMLPropertyListDomainCallBacks; + +typedef struct __CFPreferencesDomain * CFPreferencesDomainRef; + +CF_EXPORT CFPreferencesDomainRef _CFPreferencesDomainCreate(CFTypeRef context, const _CFPreferencesDomainCallBacks *callBacks); +CF_EXPORT CFPreferencesDomainRef _CFPreferencesStandardDomain(CFStringRef domainName, CFStringRef userName, CFStringRef hostName); + +CF_EXPORT CFTypeRef _CFPreferencesDomainCreateValueForKey(CFPreferencesDomainRef domain, CFStringRef key); +CF_EXPORT void _CFPreferencesDomainSet(CFPreferencesDomainRef domain, CFStringRef key, CFTypeRef value); +CF_EXPORT Boolean _CFPreferencesDomainSynchronize(CFPreferencesDomainRef domain); + +CF_EXPORT CFArrayRef _CFPreferencesCreateDomainList(CFStringRef userName, CFStringRef hostName); +CF_EXPORT Boolean _CFSynchronizeDomainCache(void); + +CF_EXPORT void _CFPreferencesDomainSetDictionary(CFPreferencesDomainRef domain, CFDictionaryRef dict); +CF_EXPORT CFDictionaryRef _CFPreferencesDomainDeepCopyDictionary(CFPreferencesDomainRef domain); +CF_EXPORT Boolean _CFPreferencesDomainExists(CFStringRef domainName, CFStringRef userName, CFStringRef hostName); + +/* HACK - this is to work around the fact that individual domains lose the information about their user/host/app triplet at creation time. We should find a better way to propogate this information. REW, 1/13/00 */ +CF_EXPORT void _CFPreferencesDomainSetIsWorldReadable(CFPreferencesDomainRef domain, Boolean isWorldReadable); + +typedef struct { + CFMutableArrayRef _search; // the search list; an array of _CFPreferencesDomains + CFMutableDictionaryRef _dictRep; // Mutable; a collapsed view of the search list, expressed as a single dictionary + CFStringRef _appName; +} _CFApplicationPreferences; + +CF_EXPORT _CFApplicationPreferences *_CFStandardApplicationPreferences(CFStringRef appName); +CF_EXPORT _CFApplicationPreferences *_CFApplicationPreferencesCreateWithUser(CFStringRef userName, CFStringRef appName); +CF_EXPORT void _CFDeallocateApplicationPreferences(_CFApplicationPreferences *self); +CF_EXPORT CFTypeRef _CFApplicationPreferencesCreateValueForKey(_CFApplicationPreferences *prefs, CFStringRef key); +CF_EXPORT void _CFApplicationPreferencesSet(_CFApplicationPreferences *self, CFStringRef defaultName, CFTypeRef value); +CF_EXPORT void _CFApplicationPreferencesRemove(_CFApplicationPreferences *self, CFStringRef defaultName); +CF_EXPORT Boolean _CFApplicationPreferencesSynchronize(_CFApplicationPreferences *self); +CF_EXPORT void _CFApplicationPreferencesUpdate(_CFApplicationPreferences *self); // same as updateDictRep +CF_EXPORT CFDictionaryRef _CFApplicationPreferencesCopyRepresentation3(_CFApplicationPreferences *self, CFDictionaryRef hint, CFDictionaryRef insertion, CFPreferencesDomainRef afterDomain); +CF_EXPORT CFDictionaryRef _CFApplicationPreferencesCopyRepresentationWithHint(_CFApplicationPreferences *self, CFDictionaryRef hint); // same as dictRep +CF_EXPORT void _CFApplicationPreferencesSetStandardSearchList(_CFApplicationPreferences *appPreferences); +CF_EXPORT void _CFApplicationPreferencesSetCacheForApp(_CFApplicationPreferences *appPrefs, CFStringRef appName); +CF_EXPORT void _CFApplicationPreferencesAddSuitePreferences(_CFApplicationPreferences *appPrefs, CFStringRef suiteName); +CF_EXPORT void _CFApplicationPreferencesRemoveSuitePreferences(_CFApplicationPreferences *appPrefs, CFStringRef suiteName); + +CF_EXPORT void _CFApplicationPreferencesAddDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain, Boolean addAtTop); +CF_EXPORT Boolean _CFApplicationPreferencesContainsDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain); +CF_EXPORT void _CFApplicationPreferencesRemoveDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain); + +CF_EXPORT CFTypeRef _CFApplicationPreferencesSearchDownToDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef stopper, CFStringRef key); + + +CF_EXTERN_C_END + + + +// ---- CFString material ---------------------------------------- + +#include + +#define NSSTRING_BOUNDSERROR \ + [NSException raise:NSRangeException format:@"%@: Range or index out of bounds", __CFExceptionProem((id)self, _cmd)] + +#define NSSTRING_RANGEERROR(range, len) \ + [NSException raise:NSRangeException format:@"%@: Range {%lu, %lu} out of bounds; string length %lu", __CFExceptionProem((id)self, _cmd), (unsigned long)range.location, (unsigned long)range.length, (unsigned long)len] + +#define NSSTRING_INDEXERROR(index, len) \ + [NSException raise:NSRangeException format:@"%@: Index %lu out of bounds; string length %lu", __CFExceptionProem((id)self, _cmd), (unsigned long)index, (unsigned long)len] + +// This can be made into an exception for post-10.10 apps +#define NSSTRING_POSSIBLE_RANGEERROR(range, len) \ + if (__CFStringNoteErrors()) { \ + static bool warnonce = false; \ + if (!warnonce) { \ + warnonce = true; \ + CFLog(kCFLogLevelWarning, CFSTR("*** %@: Range {%lu, %lu} out of bounds; string length %lu. This will become an exception for apps linked after 10.10 and iOS 8. Warning shown once per app execution."), __CFExceptionProem((id)self, _cmd), (unsigned long)range.location, (unsigned long)range.length, (unsigned long)len); \ + } \ +} + +#define NSSTRING_ILLEGALREQUESTERROR \ + [NSException raise:NSInvalidArgumentException format:@"Can't call %s in %@", sel_getName(_cmd), object_getClass((id)self)] + +#define NSSTRING_INVALIDMUTATIONERROR \ + [NSException raise:NSInvalidArgumentException format:@"Attempt to mutate immutable object with %s", sel_getName(_cmd)] + +#define NSSTRING_NULLCSTRINGERROR \ + [NSException raise:NSInvalidArgumentException format:@"%@: NULL cString", __CFExceptionProem((id)self, _cmd)] + +#define NSSTRING_NILSTRINGERROR \ + [NSException raise:NSInvalidArgumentException format:@"%@: nil argument", __CFExceptionProem((id)self, _cmd)] + + +CF_EXTERN_C_BEGIN + +/* Create a byte stream from a CFString backing. Can convert a string piece at a + time into a fixed size buffer. Returns number of characters converted. + Characters that cannot be converted to the specified encoding are represented + with the char specified by lossByte; if 0, then lossy conversion is not allowed + and conversion stops, returning partial results. + generatingExternalFile indicates that any extra stuff to allow this data to be + persistent (for instance, BOM) should be included. + Pass buffer==NULL if you don't care about the converted string (but just the + convertability, or number of bytes required, indicated by usedBufLen). + Does not zero-terminate. If you want to create Pascal or C string, allow one + extra byte at start or end. +*/ +CF_EXPORT CFIndex __CFStringEncodeByteStream(CFStringRef string, CFIndex rangeLoc, CFIndex rangeLen, Boolean generatingExternalFile, CFStringEncoding encoding, char lossByte, UInt8 *buffer, CFIndex max, CFIndex *usedBufLen); + +CF_EXPORT CFStringRef __CFStringCreateImmutableFunnel2(CFAllocatorRef alloc, const void *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean possiblyExternalFormat, Boolean tryToReduceUnicode, Boolean hasLengthByte, Boolean hasNullByte, Boolean noCopy, CFAllocatorRef contentsDeallocator); + +CF_EXPORT void __CFStringAppendBytes(CFMutableStringRef str, const char *cStr, CFIndex appendedLength, CFStringEncoding encoding); + +CF_INLINE Boolean __CFStringEncodingIsSupersetOfASCII(CFStringEncoding encoding) { + switch (encoding & 0x0000FF00) { + case 0x0: // MacOS Script range + // Symbol & bidi encodings are not ASCII superset + if (encoding == kCFStringEncodingMacJapanese || encoding == kCFStringEncodingMacArabic || encoding == kCFStringEncodingMacHebrew || encoding == kCFStringEncodingMacUkrainian || encoding == kCFStringEncodingMacSymbol || encoding == kCFStringEncodingMacDingbats) return false; + return true; + + case 0x100: // Unicode range + if (encoding != kCFStringEncodingUTF8) return false; + return true; + + case 0x200: // ISO range + if (encoding == kCFStringEncodingISOLatinArabic) return false; + return true; + + case 0x600: // National standards range + if (encoding != kCFStringEncodingASCII) return false; + return true; + + case 0x800: // ISO 2022 range + return false; // It's modal encoding + + case 0xA00: // Misc standard range + if ((encoding == kCFStringEncodingShiftJIS) || (encoding == kCFStringEncodingHZ_GB_2312) || (encoding == kCFStringEncodingUTF7_IMAP)) return false; + return true; + + case 0xB00: + if (encoding == kCFStringEncodingNonLossyASCII) return false; + return true; + + case 0xC00: // EBCDIC + return false; + + default: + return ((encoding & 0x0000FF00) > 0x0C00 ? false : true); + } +} + + +/* Desperately using extern here */ +CF_EXPORT CFStringEncoding __CFDefaultEightBitStringEncoding; +CF_EXPORT CFStringEncoding __CFStringComputeEightBitStringEncoding(void); + +CF_INLINE CFStringEncoding __CFStringGetEightBitStringEncoding(void) { + if (__CFDefaultEightBitStringEncoding == kCFStringEncodingInvalidId) __CFStringComputeEightBitStringEncoding(); + return __CFDefaultEightBitStringEncoding; +} + +enum { + __kCFVarWidthLocalBufferSize = 1008 +}; + +typedef struct { /* A simple struct to maintain ASCII/Unicode versions of the same buffer. */ + union { + UInt8 *ascii; + UniChar *unicode; + } chars; + Boolean isASCII; /* This really does mean 7-bit ASCII, not _NSDefaultCStringEncoding() */ + Boolean shouldFreeChars; /* If the number of bytes exceeds __kCFVarWidthLocalBufferSize, bytes are allocated */ + Boolean _unused1; + Boolean _unused2; + CFAllocatorRef allocator; /* Use this allocator to allocate, reallocate, and deallocate the bytes */ + CFIndex numChars; /* This is in terms of ascii or unicode; that is, if isASCII, it is number of 7-bit chars; otherwise it is number of UniChars; note that the actual allocated space might be larger */ + UInt8 localBuffer[__kCFVarWidthLocalBufferSize]; /* private; 168 ISO2022JP chars, 504 Unicode chars, 1008 ASCII chars */ +} CFVarWidthCharBuffer; + + +/* Convert a byte stream to ASCII (7-bit!) or Unicode, with a CFVarWidthCharBuffer struct on the stack. false return indicates an error occured during the conversion. Depending on .isASCII, follow .chars.ascii or .chars.unicode. If .shouldFreeChars is returned as true, free the returned buffer when done with it. If useClientsMemoryPtr is provided as non-NULL, and the provided memory can be used as is, this is set to true, and the .ascii or .unicode buffer in CFVarWidthCharBuffer is set to bytes. +!!! If the stream is Unicode and has no BOM, the data is assumed to be big endian! Could be trouble on Intel if someone didn't follow that assumption. +!!! __CFStringDecodeByteStream2() needs to be deprecated and removed post-Jaguar. +*/ +CF_EXPORT Boolean __CFStringDecodeByteStream2(const UInt8 *bytes, UInt32 len, CFStringEncoding encoding, Boolean alwaysUnicode, CFVarWidthCharBuffer *buffer, Boolean *useClientsMemoryPtr); +CF_EXPORT Boolean __CFStringDecodeByteStream3(const UInt8 *bytes, CFIndex len, CFStringEncoding encoding, Boolean alwaysUnicode, CFVarWidthCharBuffer *buffer, Boolean *useClientsMemoryPtr, UInt32 converterFlags); + + +/* Convert single byte to Unicode; assumes one-to-one correspondence (that is, can only be used with 1-byte encodings). You can use the function if it's not NULL. +*/ +CF_EXPORT Boolean (*__CFCharToUniCharFunc)(UInt32 flags, UInt8 ch, UniChar *unicodeChar); + +/* Character class functions UnicodeData-2_1_5.txt +*/ +CF_INLINE Boolean __CFIsWhitespace(UniChar theChar) { + return ((theChar < 0x21) || (theChar > 0x7E && theChar < 0xA1) || (theChar >= 0x2000 && theChar <= 0x200B) || (theChar == 0x3000)) ? true : false; +} + +/* Same as CFStringGetCharacterFromInlineBuffer() but returns 0xFFFF on out of bounds access +*/ +CF_INLINE UniChar __CFStringGetCharacterFromInlineBufferAux(CFStringInlineBuffer *buf, CFIndex idx) { + if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0xFFFF; + if (buf->directUniCharBuffer) return buf->directUniCharBuffer[idx + buf->rangeToBuffer.location]; + if (buf->directCStringBuffer) return (UniChar)(buf->directCStringBuffer[idx + buf->rangeToBuffer.location]); + if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) { + if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0; + buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength; + if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length; + CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer); + } + return buf->buffer[idx - buf->bufferedRangeStart]; +} + +/* Same as CFStringGetCharacterFromInlineBuffer(), but without the bounds checking (will return garbage or crash) +*/ +CF_INLINE UniChar __CFStringGetCharacterFromInlineBufferQuick(CFStringInlineBuffer *buf, CFIndex idx) { + if (buf->directUniCharBuffer) return buf->directUniCharBuffer[idx + buf->rangeToBuffer.location]; + if (buf->directCStringBuffer) return (UniChar)(buf->directCStringBuffer[idx + buf->rangeToBuffer.location]); + if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) { + if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0; + buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength; + if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length; + CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer); + } + return buf->buffer[idx - buf->bufferedRangeStart]; +} + + +/* These two allow specifying an alternate description function (instead of CFCopyDescription); used by NSString +*/ +CF_EXPORT void _CFStringAppendFormatAndArgumentsAux(CFMutableStringRef outputString, CFStringRef (*copyDescFunc)(void *, const void *loc), CFDictionaryRef formatOptions, CFStringRef formatString, va_list args); +CF_EXPORT CFStringRef _CFStringCreateWithFormatAndArgumentsAux(CFAllocatorRef alloc, CFStringRef (*copyDescFunc)(void *, const void *loc), CFDictionaryRef formatOptions, CFStringRef format, va_list arguments); + +CF_EXPORT void _CFStringAppendFormatAndArgumentsAux2(CFMutableStringRef outputString, CFStringRef (*copyDescFunc)(void *, const void *loc), CFStringRef (*contextDescFunc)(void *, const void *, const void *, bool, bool *), CFDictionaryRef formatOptions, CFStringRef formatString, va_list args); +CF_EXPORT CFStringRef _CFStringCreateWithFormatAndArgumentsAux2(CFAllocatorRef alloc, CFStringRef (*copyDescFunc)(void *, const void *loc), CFStringRef (*contextDescFunc)(void *, const void *, const void *, bool, bool *), CFDictionaryRef formatOptions, CFStringRef format, va_list arguments); + +/* For NSString (and NSAttributedString) usage, mutate with isMutable check +*/ +enum {_CFStringErrNone = 0, _CFStringErrNotMutable = 1, _CFStringErrNilArg = 2, _CFStringErrBounds = 3}; +CF_EXPORT int __CFStringCheckAndReplace(CFMutableStringRef str, CFRange range, CFStringRef replacement); +CF_EXPORT Boolean __CFStringNoteErrors(void); // Should string errors raise? + +/* For NSString usage, guarantees that the contents can be extracted as 8-bit bytes in the __CFStringGetEightBitStringEncoding(). +*/ +CF_EXPORT Boolean __CFStringIsEightBit(CFStringRef str); + +/* For NSCFString usage, these do range check (where applicable) but don't check for ObjC dispatch +*/ +CF_EXPORT int _CFStringCheckAndGetCharacterAtIndex(CFStringRef str, CFIndex idx, UniChar *ch); +CF_EXPORT int _CFStringCheckAndGetCharacters(CFStringRef str, CFRange range, UniChar *buffer); +CF_EXPORT CFIndex _CFStringGetLength2(CFStringRef str); +CF_EXPORT CFHashCode __CFStringHash(CFTypeRef cf); +CF_EXPORT CFHashCode CFStringHashISOLatin1CString(const uint8_t *bytes, CFIndex len); +CF_EXPORT CFHashCode CFStringHashCString(const uint8_t *bytes, CFIndex len); +CF_EXPORT CFHashCode CFStringHashCharacters(const UniChar *characters, CFIndex len); +CF_EXPORT CFHashCode CFStringHashNSString(CFStringRef str); + + +CF_EXTERN_C_END + + +// ---- Binary plist material ---------------------------------------- + +typedef const struct __CFKeyedArchiverUID * CFKeyedArchiverUIDRef; +CF_EXPORT CFTypeID _CFKeyedArchiverUIDGetTypeID(void); +CF_EXPORT CFKeyedArchiverUIDRef _CFKeyedArchiverUIDCreate(CFAllocatorRef allocator, uint32_t value); +CF_EXPORT uint32_t _CFKeyedArchiverUIDGetValue(CFKeyedArchiverUIDRef uid); + + +enum { + kCFBinaryPlistMarkerNull = 0x00, + kCFBinaryPlistMarkerFalse = 0x08, + kCFBinaryPlistMarkerTrue = 0x09, + kCFBinaryPlistMarkerFill = 0x0F, + kCFBinaryPlistMarkerInt = 0x10, + kCFBinaryPlistMarkerReal = 0x20, + kCFBinaryPlistMarkerDate = 0x33, + kCFBinaryPlistMarkerData = 0x40, + kCFBinaryPlistMarkerASCIIString = 0x50, + kCFBinaryPlistMarkerUnicode16String = 0x60, + kCFBinaryPlistMarkerUID = 0x80, + kCFBinaryPlistMarkerArray = 0xA0, + kCFBinaryPlistMarkerSet = 0xC0, + kCFBinaryPlistMarkerDict = 0xD0 +}; + +typedef struct { + uint8_t _magic[6]; + uint8_t _version[2]; +} CFBinaryPlistHeader; + +typedef struct { + uint8_t _unused[5]; + uint8_t _sortVersion; + uint8_t _offsetIntSize; + uint8_t _objectRefSize; + uint64_t _numObjects; + uint64_t _topObject; + uint64_t _offsetTableOffset; +} CFBinaryPlistTrailer; + + +CF_EXPORT bool __CFBinaryPlistGetTopLevelInfo(const uint8_t *databytes, uint64_t datalen, uint8_t *marker, uint64_t *offset, CFBinaryPlistTrailer *trailer); +CF_EXPORT bool __CFBinaryPlistGetOffsetForValueFromArray2(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFIndex idx, uint64_t *offset, CFMutableDictionaryRef objects); +CF_EXPORT bool __CFBinaryPlistGetOffsetForValueFromDictionary3(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFTypeRef key, uint64_t *koffset, uint64_t *voffset, Boolean unused, CFMutableDictionaryRef objects); +CF_EXPORT bool __CFBinaryPlistCreateObject(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFAllocatorRef allocator, CFOptionFlags mutabilityOption, CFMutableDictionaryRef objects, CFPropertyListRef *plist); +CF_EXPORT CFIndex __CFBinaryPlistWriteToStream(CFPropertyListRef plist, CFTypeRef stream); +CF_EXPORT CFIndex __CFBinaryPlistWriteToStreamWithEstimate(CFPropertyListRef plist, CFTypeRef stream, uint64_t estimate); // will be removed soon +CF_EXPORT CFIndex __CFBinaryPlistWriteToStreamWithOptions(CFPropertyListRef plist, CFTypeRef stream, uint64_t estimate, CFOptionFlags options); // will be removed soon +CF_EXPORT CFIndex __CFBinaryPlistWrite(CFPropertyListRef plist, CFTypeRef stream, uint64_t estimate, CFOptionFlags options, CFErrorRef *error); + +// ---- Used by property list parsing in Foundation + +CF_EXPORT CFTypeRef _CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags option, CFStringRef *errorString, Boolean allowNewTypes, CFPropertyListFormat *format); + +CF_EXPORT CFTypeRef _CFPropertyListCreateFromXMLString(CFAllocatorRef allocator, CFStringRef xmlString, CFOptionFlags option, CFStringRef *errorString, Boolean allowNewTypes, CFPropertyListFormat *format); + +// ---- Sudden Termination material ---------------------------------------- + +#if DEPLOYMENT_TARGET_MACOSX + +CF_EXPORT void _CFSuddenTerminationDisable(void); +CF_EXPORT void _CFSuddenTerminationEnable(void); +CF_EXPORT void _CFSuddenTerminationExitIfTerminationEnabled(int exitStatus); +CF_EXPORT void _CFSuddenTerminationExitWhenTerminationEnabled(int exitStatus); +CF_EXPORT size_t _CFSuddenTerminationDisablingCount(void); + +#endif + +// ---- Thread-specific data -------------------------------------------- + +// Get some thread specific data from a pre-assigned slot. +CF_EXPORT void *_CFGetTSD(uint32_t slot); + +// Set some thread specific data in a pre-assigned slot. Don't pick a random value. Make sure you're using a slot that is unique. Pass in a destructor to free this data, or NULL if none is needed. Unlike pthread TSD, the destructor is per-thread. +CF_EXPORT void *_CFSetTSD(uint32_t slot, void *newVal, void (*destructor)(void *)); + +#if DEPLOYMENT_TARGET_WINDOWS +// ---- Windows-specific material --------------------------------------- + +// These are replacements for POSIX calls on Windows, ensuring that the UTF8 parameters are converted to UTF16 before being passed to Windows +CF_EXPORT int _NS_stat(const char *name, struct _stat *st); +CF_EXPORT int _NS_mkdir(const char *name); +CF_EXPORT int _NS_rmdir(const char *name); +CF_EXPORT int _NS_chmod(const char *name, int mode); +CF_EXPORT int _NS_unlink(const char *name); +CF_EXPORT char *_NS_getcwd(char *dstbuf, size_t size); // Warning: this doesn't support dstbuf as null even though 'getcwd' does +CF_EXPORT char *_NS_getenv(const char *name); +CF_EXPORT int _NS_rename(const char *oldName, const char *newName); +CF_EXPORT int _NS_open(const char *name, int oflag, int pmode); +CF_EXPORT int _NS_mkstemp(char *name, int bufSize); +#endif + +// ---- Miscellaneous material ---------------------------------------- + +#include +#include +#include + +CF_EXTERN_C_BEGIN + +CF_EXPORT CFTypeID CFTypeGetTypeID(void); + +CF_EXPORT void _CFArraySetCapacity(CFMutableArrayRef array, CFIndex cap); +CF_EXPORT void _CFBagSetCapacity(CFMutableBagRef bag, CFIndex cap); +CF_EXPORT void _CFDictionarySetCapacity(CFMutableDictionaryRef dict, CFIndex cap); +CF_EXPORT void _CFSetSetCapacity(CFMutableSetRef set, CFIndex cap); + +CF_EXPORT void CFCharacterSetCompact(CFMutableCharacterSetRef theSet); +CF_EXPORT void CFCharacterSetFast(CFMutableCharacterSetRef theSet); + +CF_EXPORT const void *_CFArrayCheckAndGetValueAtIndex(CFArrayRef array, CFIndex idx); +CF_EXPORT void _CFArrayReplaceValues(CFMutableArrayRef array, CFRange range, const void **newValues, CFIndex newCount); + + +/* Enumeration + Call CFStartSearchPathEnumeration() once, then call + CFGetNextSearchPathEnumeration() one or more times with the returned state. + The return value of CFGetNextSearchPathEnumeration() should be used as + the state next time around. + When CFGetNextSearchPathEnumeration() returns 0, you're done. +*/ +typedef CFIndex CFSearchPathEnumerationState; +CF_EXPORT CFSearchPathEnumerationState __CFStartSearchPathEnumeration(CFSearchPathDirectory dir, CFSearchPathDomainMask domainMask); +CF_EXPORT CFSearchPathEnumerationState __CFGetNextSearchPathEnumeration(CFSearchPathEnumerationState state, UInt8 *path, CFIndex pathSize); + +/* For use by NSNumber and CFNumber. + Hashing algorithm for CFNumber: + M = Max CFHashCode (assumed to be unsigned) + For positive integral values: (N * HASHFACTOR) mod M + For negative integral values: ((-N) * HASHFACTOR) mod M + For floating point numbers that are not integral: hash(integral part) + hash(float part * M) + HASHFACTOR is 2654435761, from Knuth's multiplicative method +*/ +#define HASHFACTOR 2654435761U + +CF_INLINE CFHashCode _CFHashInt(long i) { + return ((i > 0) ? (CFHashCode)(i) : (CFHashCode)(-i)) * HASHFACTOR; +} + +CF_INLINE CFHashCode _CFHashDouble(double d) { + double dInt; + if (d < 0) d = -d; + dInt = floor(d+0.5); + CFHashCode integralHash = HASHFACTOR * (CFHashCode)fmod(dInt, (double)ULONG_MAX); + return (CFHashCode)(integralHash + (CFHashCode)((d - dInt) * ULONG_MAX)); +} + + +/* These four functions are used by NSError in formatting error descriptions. They take NS or CFError as arguments and return a retained CFString or NULL. +*/ +CF_EXPORT CFStringRef _CFErrorCreateLocalizedDescription(CFErrorRef err); +CF_EXPORT CFStringRef _CFErrorCreateLocalizedFailureReason(CFErrorRef err); +CF_EXPORT CFStringRef _CFErrorCreateLocalizedRecoverySuggestion(CFErrorRef err); +CF_EXPORT CFStringRef _CFErrorCreateDebugDescription(CFErrorRef err); + +CF_EXPORT void *__CFURLReservedPtr(CFURLRef url); +CF_EXPORT void __CFURLSetReservedPtr(CFURLRef url, void *ptr); +CF_EXPORT CFStringEncoding _CFURLGetEncoding(CFURLRef url); + +#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI || DEPLOYMENT_TARGET_WINDOWS +CF_EXPORT Boolean _CFRunLoopFinished(CFRunLoopRef rl, CFStringRef mode); +#endif + +CF_EXPORT CFIndex _CFStreamInstanceSize(void); + +#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED +typedef struct { + mach_vm_address_t address; + mach_vm_size_t size; + mach_port_t port; + bool purgeable; + bool corporeal; + bool volatyle; + uintptr_t reserved; +} CFDiscorporateMemory; + +extern kern_return_t _CFDiscorporateMemoryAllocate(CFDiscorporateMemory *hm, size_t size, bool purgeable); +extern kern_return_t _CFDiscorporateMemoryDeallocate(CFDiscorporateMemory *hm); +extern kern_return_t _CFDiscorporateMemoryDematerialize(CFDiscorporateMemory *hm); +extern kern_return_t _CFDiscorporateMemoryMaterialize(CFDiscorporateMemory *hm); +#endif + +enum { + kCFNumberFormatterOrdinalStyle = 6, + kCFNumberFormatterDurationStyle = 7, +}; + +// This is for NSNumberFormatter use only! +CF_EXPORT void *_CFNumberFormatterGetFormatter(CFNumberFormatterRef formatter); + +CF_EXPORT CFRange _CFDataFindBytes(CFDataRef data, CFDataRef dataToFind, CFRange searchRange, CFDataSearchFlags compareOptions); + + +#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI + #if !defined(__CFReadTSR) + #include + #define __CFReadTSR() mach_absolute_time() + #endif +#elif DEPLOYMENT_TARGET_WINDOWS +#if 0 +CF_INLINE UInt64 __CFReadTSR(void) { + LARGE_INTEGER freq; + QueryPerformanceCounter(&freq); + return freq.QuadPart; +} +#endif +#endif + + +CF_EXTERN_C_END + +#ifdef __OBJC__ +#import + +extern id _objc_rootAutorelease(id obj); + +static inline id ___CFAllocateObject2(Class cls, size_t extraBytes) { + id obj = class_createInstance(cls, extraBytes); + if (obj == NULL) { + // Good luck: it couldnt allocate room for one measly object, yet this is going to allocate atleast 2 (and probably a few more underneath) + CFStringRef reason = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("Could not allocate class %s"), class_getName(cls)); + reason = (CFStringRef)_objc_rootAutorelease((id)reason); + @throw [NSException exceptionWithName:NSMallocException reason:(NSString *)reason userInfo:NULL]; + } + return obj; +} + +static inline id ___CFAllocateObject(Class cls) { + return ___CFAllocateObject2(cls, 0); +} + +@interface NSCalendar (CoreFoundation) +- (CFRange)_minimumRangeOfUnit:(CFCalendarUnit)unit; +- (CFRange)_maximumRangeOfUnit:(CFCalendarUnit)unit; +- (CFRange)_rangeOfUnit:(CFCalendarUnit)smallerUnit inUnit:(CFCalendarUnit)biggerUnit forAT:(CFAbsoluteTime)at; +@end + +@interface NSStream (CoreFoundation) +- (CFStreamError)_cfStreamError; +- (void)_unscheduleFromCFRunLoop:(CFRunLoopRef)runLoop forMode:(CFStringRef)mode; +- (void)_scheduleInCFRunLoop:(CFRunLoopRef)runLoop forMode:(CFStringRef)mode; +@end + +@interface NSInputStream (CoreFoundation) +- (BOOL)_setCFClientFlags:(CFOptionFlags)flags callback:(CFReadStreamClientCallBack)callback context:(CFStreamClientContext *)context; +@end + +@interface NSOutputStream (CoreFoundation) +- (BOOL)_setCFClientFlags:(CFOptionFlags)flags callback:(CFWriteStreamClientCallBack)callback context:(CFStreamClientContext *)context; +@end + +@interface NSTimer (CoreFoundation) +- (CFAbsoluteTime)_cffireTime; +@end + +@interface NSTimeZone (CoreFoundation) +- (double)_daylightSavingTimeOffsetForAbsoluteTime:(double)at; +- (double)_nextDaylightSavingTimeTransitionAfterAbsoluteTime:(double)at; +@end + + +#endif + +#endif /* ! __COREFOUNDATION_FORFOUNDATIONONLY__ */ + diff --git a/include/CoreFoundation/FoundationExceptions.h b/include/CoreFoundation/FoundationExceptions.h new file mode 100644 index 0000000..5ee41c6 --- /dev/null +++ b/include/CoreFoundation/FoundationExceptions.h @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2017 Lubos Dolezel + * + * Darling is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Foobar is distributed in the hope that it will be useful, + * Darling WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + +#ifndef _FOUNDATION_EXCEPTIONS_H +#define _FOUNDATION_EXCEPTIONS_H + +#if !__OBJC2__ + +enum { + kCFDoExceptionOperationGetUncaughtHandler = 0, + kCFDoExceptionOperationSetUncaughtHandler, + kCFDoExceptionOperationRaiseError = 40, + kCFDoExceptionOperationAddHandler = 50, + kCFDoExceptionOperationRemoveHandler, + kCFDoExceptionOperationExtractException +}; + +void* _CFDoExceptionOperation(int op, void* arg); + +__attribute__((visibility("hidden"))) +void __exceptionInit(void); + +#endif + +#endif diff --git a/include/CoreFoundation/GNUstep.h b/include/CoreFoundation/GNUstep.h new file mode 100644 index 0000000..ea8ea88 --- /dev/null +++ b/include/CoreFoundation/GNUstep.h @@ -0,0 +1,79 @@ +/* GNUstep.h - macros to make easier to port gnustep apps to macos-x + Copyright (C) 2001 Free Software Foundation, Inc. + + Written by: Nicola Pero + Date: March, October 2001 + + This file is part of GNUstep. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef __GNUSTEP_GNUSTEP_H_INCLUDED_ +#define __GNUSTEP_GNUSTEP_H_INCLUDED_ + +#ifndef GNUSTEP + +#define AUTORELEASE(object) [object autorelease] +#define TEST_AUTORELEASE(object) ({ if (object) [object autorelease]; }) + +#define RELEASE(object) [object release] +#define TEST_RELEASE(object) ({ if (object) [object release]; }) + +#define RETAIN(object) [object retain] +#define TEST_RETAIN(object) ({ if (object) [object retain]; }) + +#define ASSIGN(object,value) ({\ + id __value = (id)(value); \ + id __object = (id)(object); \ + if (__value != __object) \ + { \ + if (__value != nil) \ + { \ + [__value retain]; \ + } \ + object = __value; \ + if (__object != nil) \ + { \ + [__object release]; \ + } \ + } \ + }) + +#define ASSIGNCOPY(object,value) ASSIGN(object, [[value copy] autorelease]); + +#define DESTROY(object) ({ \ + if (object) \ + { \ + id __o = object; \ + object = nil; \ + [__o release]; \ + } \ + }) + +#define CREATE_AUTORELEASE_POOL(X) \ +NSAutoreleasePool *(X) = [NSAutoreleasePool new] + +#define NSLocalizedString(key, comment) \ + [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil] + +#define _(X) NSLocalizedString (X, nil) +#define __(X) X + +#define NSLocalizedStaticString(X, Y) X + +#endif /* GNUSTEP */ + +#endif /* __GNUSTEP_GNUSTEP_H_INCLUDED_ */ diff --git a/include/CoreFoundation/GSInvocation.h b/include/CoreFoundation/GSInvocation.h new file mode 100644 index 0000000..785b015 --- /dev/null +++ b/include/CoreFoundation/GSInvocation.h @@ -0,0 +1,90 @@ +/* Interface for NSInvocation concrete classes for GNUStep + Copyright (C) 1998 Free Software Foundation, Inc. + + Written: Adam Fedor + Date: Nov 2000 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +#ifndef __GSInvocation_h_GNUSTEP_BASE_INCLUDE +#define __GSInvocation_h_GNUSTEP_BASE_INCLUDE + +#include + +@class NSMutableData; + +typedef struct { + int offset; + unsigned size; + const char *type; + const char *qtype; + unsigned align; + unsigned qual; + BOOL isReg; +} NSArgumentInfo; + + +@interface GSFFIInvocation : NSInvocation +{ +@public + uint8_t _retbuf[32]; // Store return values of up to 32 bytes here. + NSMutableData *_frame; +} +@end + +@interface GSFFCallInvocation : NSInvocation +{ +} +@end + +@interface GSDummyInvocation : NSInvocation +{ +} +@end + +@interface NSInvocation (DistantCoding) +- (BOOL) encodeWithDistantCoder: (NSCoder*)coder passPointers: (BOOL)passp; +@end + +@interface NSMethodSignature (GNUstep) +- (const char*) methodType; +- (NSArgumentInfo*) methodInfo; +@end + +extern void +GSFFCallInvokeWithTargetAndImp(NSInvocation *inv, id anObject, IMP imp); + +extern void +GSFFIInvokeWithTargetAndImp(NSInvocation *inv, id anObject, IMP imp); + +#define CLEAR_RETURN_VALUE_IF_OBJECT \ +do {\ + if (_validReturn && *_inf[0].type == _C_ID) \ + { \ + RELEASE (*(id*) _retval); \ + *(id*) _retval = nil; \ + _validReturn = NO; \ + }\ + } while (0) + +#define RETAIN_RETURN_VALUE do { if (*_inf[0].type == _C_ID) RETAIN (*(id*) _retval);} while (0) + +#define _inf ((NSArgumentInfo*)_info) + +#endif diff --git a/include/CoreFoundation/GSObjCRuntime.h b/include/CoreFoundation/GSObjCRuntime.h new file mode 100644 index 0000000..3aa0746 --- /dev/null +++ b/include/CoreFoundation/GSObjCRuntime.h @@ -0,0 +1,629 @@ +/** Interface to ObjC runtime for GNUStep + Copyright (C) 1995, 1997, 2000, 2002, 2003 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum + Date: 1995 + Written by: Richard Frith-Macdonald + Date: 2002 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + AutogsdocSource: Additions/GSObjCRuntime.m + + */ + +#ifndef __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE +#define __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE + +#include + +#define __GNU_LIBOBJC__ +#define OBJC2RUNTIME 1 +#ifndef GS_EXPORT +# define GS_EXPORT extern +#endif + +#if NeXT_RUNTIME + #include + #include + #include + #ifndef _C_ATOM + #define _C_ATOM '%' + #endif + #define _F_CONST 0x01 + #define _F_IN 0x01 + #define _F_OUT 0x02 + #define _F_INOUT 0x03 + #define _F_BYCOPY 0x04 + #define _F_ONEWAY 0x08 + #define _C_CONST 'r' + #define _C_IN 'n' + #define _C_INOUT 'N' + #define _C_OUT 'o' + #define _C_BYCOPY 'O' + #define _C_ONEWAY 'V' +#else /* GNU Objective C Runtime */ + #include + #if defined (__GNU_LIBOBJC__) + #include + #else + #include + #include + #endif +#endif + +/* + * Hack for older compiler versions that don't have all defines + * needed in objc-api.h + */ +#ifndef _C_LNG_LNG +#define _C_LNG_LNG 'q' +#endif +#ifndef _C_ULNG_LNG +#define _C_ULNG_LNG 'Q' +#endif + +#if OBJC2RUNTIME +/* We have a real ObjC2 runtime. + */ +#include +#else +/* We emulate an ObjC2 runtime. + */ +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +@class NSArray; +@class NSDictionary; +@class NSObject; +@class NSString; +@class NSValue; + +#ifndef YES +#define YES 1 +#endif +#ifndef NO +#define NO 0 +#endif +#ifndef nil +#define nil 0 +#endif + +#if !defined(_C_CONST) +#define _C_CONST 'r' +#endif +#if !defined(_C_IN) +#define _C_IN 'n' +#endif +#if !defined(_C_INOUT) +#define _C_INOUT 'N' +#endif +#if !defined(_C_OUT) +#define _C_OUT 'o' +#endif +#if !defined(_C_BYCOPY) +#define _C_BYCOPY 'O' +#endif +#if !defined(_C_BYREF) +#define _C_BYREF 'R' +#endif +#if !defined(_C_ONEWAY) +#define _C_ONEWAY 'V' +#endif +#if !defined(_C_GCINVISIBLE) +#define _C_GCINVISIBLE '!' +#endif + +/* + * Functions for accessing instance variables directly - + * We can copy an ivar into arbitrary data, + * Get the type encoding for a named ivar, + * and copy a value into an ivar. + */ +GS_EXPORT BOOL +GSObjCFindVariable(id obj, const char *name, + const char **type, unsigned int *size, int *offset); + +GS_EXPORT void +GSObjCGetVariable(id obj, int offset, unsigned int size, void *data); + +GS_EXPORT void +GSObjCSetVariable(id obj, int offset, unsigned int size, const void *data); + +GS_EXPORT NSArray * +GSObjCMethodNames(id obj, BOOL recurse); + +GS_EXPORT NSArray * +GSObjCVariableNames(id obj, BOOL recurse); + +/** + *

A Behavior can be seen as a "Protocol with an implementation" or a + * "Class without any instance variables". A key feature of behaviors + * is that they give a degree of multiple inheritance. + *

+ *

Behavior methods, when added to a class, override the class's + * superclass methods, but not the class's methods. + *

+ *

Whan a behavior class is added to a receiver class, not only are the + * methods defined in the behavior class added, but the methods from the + * behavior's class hierarchy are also added (unless already present). + *

+ *

It's not the case that a class adding behaviors from another class + * must have "no instance vars". The receiver class just has to have the + * same layout as the behavior class (optionally with some additional + * ivars after those of the behavior class). + *

+ *

This function provides Behaviors without adding any new syntax to + * the Objective C language. Simply define a class with the methods you + * want to add, then call this function with that class as the behavior + * argument. + *

+ *

This function should be called in the +initialize method of the receiver. + *

+ *

If you add several behaviors to a class, be aware that the order of + * the additions is significant. + *

+ */ +GS_EXPORT void +GSObjCAddClassBehavior(Class receiver, Class behavior); + +/** + *

An Override can be seen as a "category implemented as a separate class + * and manually added to the receiver class under program control, rather + * than automatically added by the compiler/runtime. + *

+ *

Override methods, when added to a receiver class, replace the class's + * class's methods of the same name (or are added if the class did not define + * methods with that name). + *

+ *

It's not the case that a class adding overrides from another class + * must have "no instance vars". The receiver class just has to have the + * same layout as the override class (optionally with some additional + * ivars after those of the override class). + *

+ *

This function provides overrides without adding any new syntax to + * the Objective C language. Simply define a class with the methods you + * want to add, then call this function with that class as the override + * argument. + *

+ *

This function should usually be called in the +initialize method + * of the receiver. + *

+ *

If you add several overrides to a class, be aware that the order of + * the additions is significant. + *

+ */ +GS_EXPORT void +GSObjCAddClassOverride(Class receiver, Class override); + +/** Turn on (YES), off (NO) or test (-1) behavior debugging. + */ +GS_EXPORT BOOL GSObjCBehaviorDebug(int setget); + +GS_EXPORT NSValue * +GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars); + +GS_EXPORT void +GSObjCAddClasses(NSArray *classes); + +/** + * Given a NULL terminated list of methods, add them to the class.
+ * If the method already exists in a superclass, the new version overrides + * that one, but if the method already exists in the class itsself, the + * new one is quietly ignored (replace==NO) or replaced with the new + * version (if replace==YES).
+ * To add class methods, cls should be the metaclass of the class to + * which the methods are being added. + */ +GS_EXPORT void +GSObjCAddMethods(Class cls, Method *list, BOOL replace); + +/* + * Functions for key-value encoding ... they access values in an object + * either by selector or directly, but do so using NSNumber for the + * scalar types of data. + */ +GS_EXPORT id +GSObjCGetVal(NSObject *self, const char *key, SEL sel, + const char *type, unsigned size, int offset); + +GS_EXPORT void +GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel, + const char *type, unsigned size, int offset); + +/* + * This section includes runtime functions + * to query and manipulate the ObjC runtime structures. + * These functions take care to not use ObjC code so + * that they can safely be used in +(void)load implementations + * where applicable. + */ + +/** + * Deprecated ... use objc_getClassList() + */ +GS_EXPORT unsigned int +GSClassList(Class *buffer, unsigned int max, BOOL clearCache); + +/** + * GSObjCClass() is deprecated ... use object_getClass() + */ +GS_EXPORT Class GSObjCClass(id obj); + +/** + * GSObjCSuper() is deprecated ... use class_getSuperclass() + */ +GS_EXPORT Class GSObjCSuper(Class cls); + +/** + * GSObjCIsInstance() is deprecated ... use object_getClass() + * in conjunction with class_isMetaClass() + */ +GS_EXPORT BOOL GSObjCIsInstance(id obj); + +/** + * GSObjCIsClass() is deprecated ... use object_getClass() + * in conjunction with class_isMetaClass() + */ +GS_EXPORT BOOL GSObjCIsClass(Class cls); + +/** + * Test to see if class inherits from another class + * The argument to this function must NOT be nil. + */ +GS_EXPORT BOOL GSObjCIsKindOf(Class cls, Class other); + +/** + * GSClassFromName() is deprecated ... use objc_lookUpClass() + */ +GS_EXPORT Class GSClassFromName(const char *name); + +/** + * GSNameFromClass() is deprecated ... use class_getName() + */ +GS_EXPORT const char *GSNameFromClass(Class cls); + +/** + * GSClassNameFromObject() is deprecated ... use object_getClass() + * in conjunction with class_getName() + */ +GS_EXPORT const char *GSClassNameFromObject(id obj); + +/** + * GSNameFromSelector() is deprecated ... use sel_getName() + */ +GS_EXPORT const char *GSNameFromSelector(SEL sel); + +/** + * GSSelectorFromName() is deprecated ... use sel_getUid() + */ +GS_EXPORT SEL +GSSelectorFromName(const char *name); + +/** + * Return the selector for the specified name and types.
+ * Returns a nul pointer if the name is nul.
+ * Creates a new selector if necessary.
+ * Code must NOT rely on this providing a selector with type information. + */ +GS_EXPORT SEL +GSSelectorFromNameAndTypes(const char *name, const char *types); + +/** + * Return the type information from the specified selector.
+ * May return a nul pointer if the selector was a nul pointer or if it + * was not typed (or if the runtime does not support typed selectors).
+ * Code must NOT rely on this providing any type information. + */ +GS_EXPORT const char * +GSTypesFromSelector(SEL sel); + +/** + * Compare only the type information ignoring qualifiers, the frame layout + * and register markers. Unlike sel_types_match, this function also + * handles comparisons of types with and without any layout information. + */ +GS_EXPORT BOOL +GSSelectorTypesMatch(const char *types1, const char *types2); + +/** Takes full type information and skips forward to the actual type + * as specified in the _C_... constants. + */ +GS_EXPORT const char * +GSSkipTypeQualifierAndLayoutInfo(const char *types); + +/** + * Returns a protocol object with the corresponding name. + * This function searches the registered classes for any protocol + * with the supplied name. If one is found, it is cached in + * for future requests. If efficiency is a factor then use + * GSRegisterProtocol() to insert a protocol explicitly into the cache + * used by this function. If no protocol is found this function returns + * nil. + */ +GS_EXPORT Protocol * +GSProtocolFromName(const char *name); + +/** + * Registers proto in the cache used by GSProtocolFromName(). + */ +GS_EXPORT void +GSRegisterProtocol(Protocol *proto); + +/** + * A variant of protocol_getMethodDescription which recursively searches + * parent protocols if the requested selector isn't found in the given + * protocol. + * + * Returns a {NULL, NULL} structure if the requested selector couldn't be + * found. + */ +GS_EXPORT struct objc_method_description +GSProtocolGetMethodDescriptionRecursive(Protocol *aProtocol, SEL aSel, BOOL isRequired, BOOL isInstance); + +/* + * Unfortunately the definition of the symbols + * 'Method(_t)', 'MethodList(_t)' and 'IVar(_t)' + * are incompatible between the GNU and NeXT/Apple runtimes. + * We introduce GSMethod, GSMethodList and GSIVar to allow portability. + */ +typedef Method GSMethod; +typedef Ivar GSIVar; + +/** + * Returns the pointer to the method structure + * for the selector in the specified class. + * Depending on searchInstanceMethods, this function searches + * either instance or class methods. + * Depending on searchSuperClassesm this function searches + * either the specified class only or also its superclasses.
+ * To obtain the implementation pointer IMP use returnValue->method_imp + * which should be safe across all runtimes.
+ * It should be safe to use this function in +load implementations.
+ * This function should currently (June 2004) be considered WIP. + * Please follow potential changes (Name, parameters, ...) closely until + * it stabilizes. + */ +GS_EXPORT GSMethod +GSGetMethod(Class cls, SEL sel, + BOOL searchInstanceMethods, + BOOL searchSuperClasses); + +/** + * Deprecated .. does nothing. + */ +GS_EXPORT void +GSFlushMethodCacheForClass (Class cls); + +/** + * Deprecated .. use class_getInstanceVariable() + */ +GS_EXPORT GSIVar +GSCGetInstanceVariableDefinition(Class cls, const char *name); + +/** + * Deprecated .. use class_getInstanceVariable() + */ +GS_EXPORT GSIVar +GSObjCGetInstanceVariableDefinition(Class cls, NSString *name); + +/** + * GSObjCVersion() is deprecated ... use class_getVersion() + */ +GS_EXPORT int GSObjCVersion(Class cls); + +/** + * Quickly return autoreleased data storage area. + */ +GS_EXPORT void * +GSAutoreleasedBuffer(unsigned size); + +/** + *

Prints a message to fptr using the format string provided and any + * additional arguments. The format string is interpreted as by + * the NSString formatted initialisers, and understands the '%@' syntax + * for printing an object. + *

+ *

The data is written to the file pointer in the default CString + * encoding if possible, as a UTF8 string otherwise. + *

+ *

This function is recommended for printing general log messages. + * For debug messages use NSDebugLog() and friends. For error logging + * use NSLog(), and for warnings you might consider NSWarnLog(). + *

+ */ +GS_EXPORT BOOL +GSPrintf (FILE *fptr, NSString *format, ...); + + + +GS_EXPORT NSArray * +GSObjCAllSubclassesOfClass(Class cls); + +GS_EXPORT NSArray * +GSObjCDirectSubclassesOfClass(Class cls); + +/** Function to change the class of the specified instance to newClass. + * This handles memory debugging issues in GNUstep-base and also + * deals with class finalisation issues in a garbage collecting + * environment, so you should use this function rather than attempting + * to swizzle class pointers directly. + */ +GS_EXPORT void +GSClassSwizzle(id instance, Class newClass); + +GS_EXPORT const char * +GSLastErrorStr(long error_id); + + + +#ifndef GS_MAX_OBJECTS_FROM_STACK +/** + * The number of objects to try to get from varargs into an array on + * the stack ... if there are more than this, use the heap. + * NB. This MUST be a multiple of 2 + */ +#define GS_MAX_OBJECTS_FROM_STACK 128 +#endif + +/** + *

This is a macro designed to minimise the use of memory allocation and + * deallocation when you need to work with a vararg list of objects.
+ * The objects are unpacked from the vararg list into two 'C' arrays and + * then a code fragment you specify is able to make use of them before + * that 'C' array is destroyed. + *

+ *

The firstObject argument is the name of the formal parameter in your + * method or function which precedes the ', ...' denoting variable args. + *

+ *

The code argument is a piece of objective-c code to be executed to + * make use of the objects stored in the 'C' arrays.
+ * When this code is called the unsigned integer '__count' will contain the + * number of objects unpacked, the pointer '__objects' will point to + * the first object in each pair, and the pointer '__pairs' will point + * to an array containing the second halves of the pairs of objects + * whose first halves are in '__objects'.
+ * This lets you pack a list of the form 'key, value, key, value, ...' + * into an array of keys and an array of values. + *

+ */ +#define GS_USEIDPAIRLIST(firstObject, code...) ({\ + va_list __ap; \ + unsigned int __max = GS_MAX_OBJECTS_FROM_STACK; \ + unsigned int __count = 0; \ + id __buf[__max]; \ + id *__objects = __buf; \ + id *__pairs = &__objects[__max/2]; \ + id __obj = firstObject; \ + va_start(__ap, firstObject); \ + while (__obj != nil && __count < __max) \ + { \ + if ((__count % 2) == 0) \ + { \ + __objects[__count/2] = __obj; \ + } \ + else \ + { \ + __pairs[__count/2] = __obj; \ + } \ + __obj = va_arg(__ap, id); \ + if (++__count == __max) \ + { \ + while (__obj != nil) \ + { \ + __count++; \ + __obj = va_arg(__ap, id); \ + } \ + } \ + } \ + if ((__count % 2) == 1) \ + { \ + __pairs[__count/2] = nil; \ + __count++; \ + } \ + va_end(__ap); \ + if (__count > __max) \ + { \ + unsigned int __tmp; \ + __objects = (id*)malloc(__count*sizeof(id)); \ + __pairs = &__objects[__count/2]; \ + __objects[0] = firstObject; \ + va_start(__ap, firstObject); \ + for (__tmp = 1; __tmp < __count; __tmp++) \ + { \ + if ((__tmp % 2) == 0) \ + { \ + __objects[__tmp/2] = va_arg(__ap, id); \ + } \ + else \ + { \ + __pairs[__tmp/2] = va_arg(__ap, id); \ + } \ + } \ + va_end(__ap); \ + } \ + code; \ + if (__objects != __buf) free(__objects); \ +}) + +/** + *

This is a macro designed to minimise the use of memory allocation and + * deallocation when you need to work with a vararg list of objects.
+ * The objects are unpacked from the vararg list into a 'C' array and + * then a code fragment you specify is able to make use of them before + * that 'C' array is destroyed. + *

+ *

The firstObject argument is the name of the formal parameter in your + * method or function which precedes the ', ...' denoting variable args. + *

+ *

The code argument is a piece of objective-c code to be executed to + * make use of the objects stored in the 'C' array.
+ * When this code is called the unsigned integer '__count' will contain the + * number of objects unpacked, and the pointer '__objects' will point to + * the unpacked objects, ie. firstObject followed by the vararg arguments + * up to (but not including) the first nil. + *

+ */ +#define GS_USEIDLIST(firstObject, code...) ({\ + va_list __ap; \ + unsigned int __max = GS_MAX_OBJECTS_FROM_STACK; \ + unsigned int __count = 0; \ + id __buf[__max]; \ + id *__objects = __buf; \ + id __obj = firstObject; \ + va_start(__ap, firstObject); \ + while (__obj != nil && __count < __max) \ + { \ + __objects[__count] = __obj; \ + __obj = va_arg(__ap, id); \ + if (++__count == __max) \ + { \ + while (__obj != nil) \ + { \ + __count++; \ + __obj = va_arg(__ap, id); \ + } \ + } \ + } \ + va_end(__ap); \ + if (__count > __max) \ + { \ + unsigned int __tmp; \ + __objects = (id*)NSZoneMalloc(NSDefaultMallocZone(),__count*sizeof(id)); \ + va_start(__ap, firstObject); \ + __objects[0] = firstObject; \ + for (__tmp = 1; __tmp < __count; __tmp++) \ + { \ + __objects[__tmp] = va_arg(__ap, id); \ + } \ + va_end(__ap); \ + } \ + code; \ + if (__objects != __buf) NSZoneFree (NSDefaultMallocZone(),__objects); \ +}) + + +#ifdef __cplusplus +} +#endif + +#endif /* __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */ diff --git a/include/CoreFoundation/NSBasicHash.h b/include/CoreFoundation/NSBasicHash.h new file mode 100644 index 0000000..bfc819a --- /dev/null +++ b/include/CoreFoundation/NSBasicHash.h @@ -0,0 +1,96 @@ +#import + +#define NUM_BUCKET_SIZES 64 + +static const NSUInteger __NSBasicHashIPrimes[NUM_BUCKET_SIZES] = { + 0, 3, 7, 13, 23, 41, 71, 127, 191, 251, 383, 631, 1087, 1723, + 2803, 4523, 7351, 11959, 19447, 31231, 50683, 81919, 132607, + 214519, 346607, 561109, 907759, 1468927, 2376191, 3845119, + 6221311, 10066421, 16287743, 26354171, 42641881, 68996069, + 111638519, 180634607, 292272623, 472907251, +#if __LP64__ + 765180413UL, 1238087663UL, 2003267557UL, 3241355263UL, 5244622819UL, +#if 0 + 8485977589UL, 13730600407UL, 22216578047UL, 35947178479UL, + 58163756537UL, 94110934997UL, 152274691561UL, 246385626107UL, + 398660317687UL, 645045943807UL, 1043706260983UL, 1688752204787UL, + 2732458465769UL, 4421210670577UL, 7153669136377UL, + 11574879807461UL, 18728548943849UL, 30303428750843UL +#endif +#endif +}; + +static const NSUInteger __NSBasicHashCapacities[NUM_BUCKET_SIZES] = { + 0, 3, 6, 11, 19, 32, 52, 85, 118, 155, 237, 390, 672, 1065, + 1732, 2795, 4543, 7391, 12019, 19302, 31324, 50629, 81956, + 132580, 214215, 346784, 561026, 907847, 1468567, 2376414, + 3844982, 6221390, 10066379, 16287773, 26354132, 42641916, + 68996399, 111638327, 180634415, 292272755, +#if __LP64__ + 472907503UL, 765180257UL, 1238087439UL, 2003267722UL, 3241355160UL, +#if 0 + 5244622578UL, 8485977737UL, 13730600347UL, 22216578100UL, + 35947178453UL, 58163756541UL, 94110935011UL, 152274691274UL, + 246385626296UL, 398660317578UL, 645045943559UL, 1043706261135UL, + 1688752204693UL, 2732458465840UL, 4421210670552UL, + 7153669136706UL, 11574879807265UL, 18728548943682UL +#endif +#endif +}; + +static inline NSUInteger __NSBasicHashGetSizeIdx(NSUInteger size) { + for (NSUInteger idx = 0; idx < NUM_BUCKET_SIZES; idx++) { + if (__NSBasicHashCapacities[idx] > size) { + return idx; + } + } + + DEBUG_BREAK(); + return NSNotFound; +} + +static inline void *NSBasicHashAllocate(NSUInteger count, size_t size, NSUInteger *capacity, NSUInteger *sizeidx, BOOL throwOnMallocFailure) { + *sizeidx = __NSBasicHashGetSizeIdx(count); + *capacity = __NSBasicHashIPrimes[*sizeidx]; + void *buffer = calloc(*capacity, size); + if (buffer == NULL && throwOnMallocFailure) { + [NSException raise:NSMallocException format:@"Unable to allocate buffer"]; + } + return buffer; +} + +static inline void *NSBasicHashGrow(NSUInteger count, size_t size, void *buffer, NSUInteger *capacity, NSUInteger *sizeidx, BOOL throwOnMallocFailure) { + if (*capacity < count) { + *sizeidx = __NSBasicHashGetSizeIdx(count); + *capacity = __NSBasicHashIPrimes[*sizeidx]; + void *newBuffer = realloc(buffer, (*capacity) * size); + if (newBuffer == NULL && throwOnMallocFailure) { + free(buffer); + *capacity = 0; + [NSException raise:NSMallocException format:@"Unable to reallocate buffer"]; + } + buffer = newBuffer; + } + return buffer; +} + +static inline void *NSBasicHashTrim(NSUInteger count, size_t size, void *buffer, NSUInteger *capacity, BOOL throwOnMallocFailure) { + if (*capacity > count) { + void *newBuffer = realloc(buffer, count * size); + if (newBuffer == NULL && throwOnMallocFailure) { // very sad day indeed if trimming causes malloc failure... + free(buffer); + *capacity = 0; + [NSException raise:NSMallocException format:@"Unable to reallocate buffer"]; + } else { + *capacity = count * size; + } + buffer = newBuffer; + } + return buffer; +} + +static inline void NSBasicHashDeallocate(void *buffer) { + if (buffer) { + free(buffer); + } +} diff --git a/include/CoreFoundation/NSBlock.h b/include/CoreFoundation/NSBlock.h new file mode 100644 index 0000000..40ba9bb --- /dev/null +++ b/include/CoreFoundation/NSBlock.h @@ -0,0 +1,85 @@ +#import +#import + +BLOCK_EXPORT void * _NSConcreteMallocBlock[32]; +BLOCK_EXPORT void * _NSConcreteAutoBlock[32]; +BLOCK_EXPORT void * _NSConcreteFinalizingBlock[32]; +BLOCK_EXPORT void * _NSConcreteWeakBlockVariable[32]; +BLOCK_EXPORT void * _NSConcreteGlobalBlock[32]; +BLOCK_EXPORT void * _NSConcreteStackBlock[32]; + +extern bool _Block_tryRetain(const void *aBlock); +extern bool _Block_isDeallocating(const void *aBlock); + +@interface NSBlock : NSObject + +- (void)performAfterDelay:(NSTimeInterval)delay; +- (void)invoke; +- (id)copyWithZone:(NSZone *)zone; +- (id)copy; + +@end + +@interface __NSStackBlock : NSBlock + +- (id)autorelease; +- (NSUInteger)retainCount; +- (oneway void)release; +- (id)retain; + +@end + +@interface __NSMallocBlock : NSBlock + +- (BOOL)_isDeallocating; +- (BOOL)_tryRetain; +- (unsigned int)retainCount; +- (oneway void)release; +- (id)retain; + +@end + +@interface __NSAutoBlock : NSBlock + +- (id)copyWithZone:(NSZone *)zone; +- (id)copy; + +@end + +@interface __NSFinalizingBlock : __NSAutoBlock + +- (void)finalize; + +@end + +@interface __NSGlobalBlock : NSBlock + +- (BOOL)_isDeallocating; +- (BOOL)_tryRetain; +- (NSUInteger)retainCount; +- (id)retain; +- (oneway void)release; +- (id)copyWithZone:(NSZone *)zone; +- (id)copy; + +@end + +struct Block_byref { + void *_field1; + struct Block_byref *_field2; + int _field3; + unsigned int _field4; + void *_field5; + void *_field6; +}; + +@interface __NSBlockVariable : NSObject { + struct Block_byref *forwarding; + int flags; + int size; + void *byref_keep; + void *byref_destroy; + id containedObject; +} + +@end diff --git a/include/CoreFoundation/NSGenericDeallocHandler.h b/include/CoreFoundation/NSGenericDeallocHandler.h new file mode 100644 index 0000000..122e226 --- /dev/null +++ b/include/CoreFoundation/NSGenericDeallocHandler.h @@ -0,0 +1,16 @@ +#import + +void _NSSetDeallocHandler(id object, void (^block)(void)); + +__attribute__((visibility("hidden"), objc_root_class)) +@interface __NSGenericDeallocHandler { + Class isa; + void (^_block)(void); +} + ++ (void)initialize; +- (void)release; +- (NSUInteger)retainCount; +- (id)retain; + +@end diff --git a/include/CoreFoundation/NSInvocationInternal.h b/include/CoreFoundation/NSInvocationInternal.h new file mode 100644 index 0000000..1b8d0e0 --- /dev/null +++ b/include/CoreFoundation/NSInvocationInternal.h @@ -0,0 +1,10 @@ +#import + +// By grabbing at least 4 words for retSize, we can blindly copy r0-r3 +// into retdata when returning from an invocation. +#define RET_SIZE_ARGS (4 * sizeof(int)) + +void __invoke__(void *send, void *retdata, marg_list args, size_t len, const char *rettype); + +extern void _CF_forwarding_prep_0(); +extern void _CF_forwarding_prep_1(); \ No newline at end of file diff --git a/include/CoreFoundation/NSMessageBuilder.h b/include/CoreFoundation/NSMessageBuilder.h new file mode 100644 index 0000000..10c6612 --- /dev/null +++ b/include/CoreFoundation/NSMessageBuilder.h @@ -0,0 +1,19 @@ +#import +#import + +extern id _NSMessageBuilder(id proxy, NSInvocation **inv, SEL _cmd, void *arg); + +NS_ROOT_CLASS +@interface __NSMessageBuilder +{ +@public + Class isa; + id _target; + id *_addr; +} + ++ (void)initialize; +- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel; +- (void)forwardInvocation:(NSInvocation *)inv; + +@end diff --git a/include/CoreFoundation/NSNumberInternal.h b/include/CoreFoundation/NSNumberInternal.h new file mode 100644 index 0000000..3c47786 --- /dev/null +++ b/include/CoreFoundation/NSNumberInternal.h @@ -0,0 +1,91 @@ +#import "NSObjectInternal.h" +#import "CFInternal.h" +#import + +CF_EXPORT Boolean _CFNumberGetValue(CFNumberRef number, CFNumberType type, void *valuePtr); +CF_EXPORT CFNumberType _CFNumberGetType(CFNumberRef num); +CF_EXPORT CFNumberType _CFNumberGetType2(CFNumberRef number); +CF_EXPORT CFStringRef __CFNumberCreateFormattingDescription(CFAllocatorRef allocator, CFTypeRef cf, CFDictionaryRef formatOptions); + +__attribute__((visibility("hidden"))) +@interface __NSCFNumber : __NSCFType + ++ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key; +- (NSComparisonResult)compare:(id)other; +- (NSComparisonResult)_reverseCompare:(id)other; +- (Boolean)_getValue:(void *)value forType:(CFNumberType)type; +- (CFNumberType)_cfNumberType; +- (CFTypeID)_cfTypeID; +- (BOOL)boolValue; +- (unsigned int)unsignedIntegerValue; +- (int)integerValue; +- (double)doubleValue; +- (float)floatValue; +- (unsigned long long)unsignedLongLongValue; +- (long long)longLongValue; +- (unsigned long)unsignedLongValue; +- (long)longValue; +- (unsigned int)unsignedIntValue; +- (int)intValue; +- (unsigned short)unsignedShortValue; +- (short)shortValue; +- (unsigned char)unsignedCharValue; +- (BOOL)charValue; +- (const char *)objCType; +- (void)getValue:(void *)value; +- (id)copyWithZone:(NSZone *)zone; +- (id)stringValue; +- (id)description; +- (id)descriptionWithLocale:(id)locale; +- (unsigned int)retainCount; +- (BOOL)_isDeallocating; +- (BOOL)_tryRetain; +- (oneway void)release; +- (id)retain; +- (NSUInteger)hash; +- (BOOL)isEqual:(id)other; +- (BOOL)isEqualToNumber:(id)other; +- (BOOL)isNSNumber__; + +@end + +__attribute__((visibility("hidden"))) +@interface __NSCFBoolean : __NSCFType + ++ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key; +- (NSComparisonResult)compare:(id)other; +- (NSComparisonResult)_reverseCompare:(id)other; +- (BOOL)_getValue:(void *)val forType:(CFNumberType)type; +- (CFNumberType)_cfNumberType; +- (id)copyWithZone:(NSZone *)zone; +- (const char *)objCType; +- (void)getValue:(void *)value; +- (CFTypeID)_cfTypeID; +- (BOOL)boolValue; +- (unsigned int)unsignedIntegerValue; +- (int)integerValue; +- (double)doubleValue; +- (float)floatValue; +- (unsigned long long)unsignedLongLongValue; +- (long long)longLongValue; +- (unsigned long)unsignedLongValue; +- (long)longValue; +- (unsigned int)unsignedIntValue; +- (int)intValue; +- (unsigned short)unsignedShortValue; +- (short)shortValue; +- (unsigned char)unsignedCharValue; +- (BOOL)charValue; +- (id)stringValue; +- (id)description; +- (id)descriptionWithLocale:(id)locale; +- (unsigned int)retainCount; +- (BOOL)_isDeallocating; +- (BOOL)_tryRetain; +- (oneway void)release; +- (id)retain; +- (unsigned int)hash; +- (BOOL)isEqual:(id)other; +- (BOOL)isEqualToNumber:(id)otherNumber; + +@end diff --git a/include/CoreFoundation/NSObjCRuntimeInternal.h b/include/CoreFoundation/NSObjCRuntimeInternal.h new file mode 100644 index 0000000..404886f --- /dev/null +++ b/include/CoreFoundation/NSObjCRuntimeInternal.h @@ -0,0 +1,24 @@ +#include + +static inline const char *stripQualifiersAndComments(const char *decl) +{ + static const char *qualifiersAndComments = "nNoOrRV\""; + + // Skip type qualifiers. + while (*decl != 0 && strchr(qualifiersAndComments, *decl)) { + if (*decl == '"') { + decl++; + while (*decl++ != '"'); + } + else { + decl++; + } + } + + return decl; +} + + +const char *__NSGetSizeAndAlignment(const char *decl, NSUInteger *size, NSUInteger *alignment, BOOL stripSizeHints); + +#define _C_LNG_DBL 'D' //add missing long double method signature constant character diff --git a/include/CoreFoundation/NSSharedKeyDictionary.h b/include/CoreFoundation/NSSharedKeyDictionary.h new file mode 100644 index 0000000..9175e5a --- /dev/null +++ b/include/CoreFoundation/NSSharedKeyDictionary.h @@ -0,0 +1,30 @@ +#import +#import "NSSharedKeySet.h" + +@interface NSSharedKeyDictionary : NSMutableDictionary { + NSSharedKeySet *_keyMap; + NSUInteger _count; + id *_values; + NSUInteger (*_ifkIMP)(id,SEL,id); + NSMutableDictionary *_sideDic; + NSUInteger _mutations; +} + ++ (id)sharedKeyDictionaryWithKeySet:(NSSharedKeySet *)keySet; +- (id)initWithKeySet:(NSSharedKeySet *)keySet; +- (id)initWithCoder:(NSCoder *)coder; +- (void)encodeWithCoder:(NSCoder *)coder; +- (Class)classForCoder; +- (id)mutableCopyWithZone:(NSZone *)zone; +- (id)copyWithZone:(NSZone *)zone; +- (void)dealloc; +- (NSSharedKeySet *)keySet; +- (void)removeObjectForKey:(id)key; +- (void)setObject:(id)object forKey:(id)key; +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained [])buffer count:(NSUInteger)len; +- (NSEnumerator *)keyEnumerator; +- (void)getObjects:(id *)objects andKeys:(id *)keys count:(NSUInteger)count; +- (id)objectForKey:(id)key; +- (NSUInteger)count; + +@end diff --git a/include/CoreFoundation/NSSharedKeySet.h b/include/CoreFoundation/NSSharedKeySet.h new file mode 100644 index 0000000..b5688a1 --- /dev/null +++ b/include/CoreFoundation/NSSharedKeySet.h @@ -0,0 +1,29 @@ +#import + +@class NSString; + +@interface NSSharedKeySet : NSObject +{ + NSUInteger _numKey; + id *_keys; + NSSharedKeySet *_subSharedKeySet; +} + ++ (id)keySetWithKeys:(NSArray *)keys; +- (NSUInteger)keySetCount; +- (void)dealloc; +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained [])buffer count:(NSUInteger)len; +- (id)keyAtIndex:(NSUInteger)index; +- (NSUInteger)indexForKey:(id)key; +- (NSArray *)allKeys; +- (NSUInteger)maximumIndex; +- (BOOL)isEmpty; +- (NSUInteger)count; +- (id)initWithCoder:(NSCoder *)coder; +- (void)encodeWithCoder:(NSCoder *)coder; +- (id)copyWithZone:(NSZone *)zone; +- (id)init; +- (id)initWithKeys:(id *)keys count:(NSUInteger)count; +- (void)createSubclassCode:(NSString *)subclassName interface:(CFStringRef *)interface implementation:(CFStringRef *)implementation; + +@end diff --git a/include/CoreFoundation/NSZombie.h b/include/CoreFoundation/NSZombie.h new file mode 100644 index 0000000..f9acaaf --- /dev/null +++ b/include/CoreFoundation/NSZombie.h @@ -0,0 +1,14 @@ +#import +#import + +#define ZOMBIE_PREFIX "_NSZombie_" + +extern uint8_t __CFZombieEnabled; +extern uint8_t __CFDeallocateZombies; + +NS_ROOT_CLASS +@interface _NSZombie_ { + Class isa; +} + +@end diff --git a/include/CoreFoundation/TargetConditionals.h b/include/CoreFoundation/TargetConditionals.h new file mode 100644 index 0000000..e9f4c6e --- /dev/null +++ b/include/CoreFoundation/TargetConditionals.h @@ -0,0 +1,17 @@ +/* TargetConditionals.h + Copyright (c) 2010-2014, Apple Inc. All rights reserved. + For CF on Linux ONLY +*/ + +#ifndef __TARGETCONDITIONALS__ +#define __TARGETCONDITIONALS__ + +#define TARGET_OS_MAC 0 +#define TARGET_OS_WIN32 0 +#define TARGET_OS_UNIX 0 +#define TARGET_OS_EMBEDDED 0 +#define TARGET_OS_IPHONE 0 +#define TARGET_IPHONE_SIMULATOR 0 +#define TARGET_OS_LINUX 1 + +#endif /* __TARGETCONDITIONALS__ */ diff --git a/include/CoreFoundation/_CFUtilities.h b/include/CoreFoundation/_CFUtilities.h new file mode 100644 index 0000000..a78ae87 --- /dev/null +++ b/include/CoreFoundation/_CFUtilities.h @@ -0,0 +1,10 @@ +#include +#include + +static char *CFStringUTF8Copy(CFStringRef cfString) { + CFIndex length = CFStringGetLength(cfString); + CFIndex size = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8); + char *buffer = (char *)malloc(size); + CFStringGetCString(cfString, buffer, size, kCFStringEncodingUTF8); + return buffer; +}